-
Notifications
You must be signed in to change notification settings - Fork 2
133 lines (110 loc) · 4.39 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
on:
push:
branches:
- main
workflow_dispatch:
name: Validate, generate and publish registry
jobs:
upload-registry:
name: Upload to Cloudflare Pages
runs-on: ubuntu-latest
permissions:
contents: 'write'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: bun install --no-save
- name: Validate schema
run: bun validate:schema
- name: Generate registry types
run: bun generate:types
- name: Check env variables
run: |
if [ -z "${{ vars.REGISTRY_ROOT_URL }}" ]; then
echo "Error: REGISTRY_ROOT_URL is not set"
exit 1
fi
if [ -z "${{ env.THEGRAPH_STUDIO_KEY }}" ]; then
echo "Error: secrets.THEGRAPH_STUDIO_KEY is not set - can't validate networks"
exit 1
fi
- name: Validate logic
run: bun validate:networks
- name: Generate registry
run: bun generate:public
- name: Generate table
run: bun generate:table
- name: Format
run: bun format
- name: Get version
id: get_version
run: |
VERSION=$(jq -r '.version' package.json)
echo "REGISTRY_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Check if tag exists
id: check_tag
run: |
if git fetch --tags && git tag -l | grep -q "v${{ env.REGISTRY_VERSION }}"; then
echo "Error: Registry v${{ env.REGISTRY_VERSION }} already exists. Bump up the version in package.json to publish"
exit 1
fi
- name: Publish
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy public --project-name=graphregistry
- name: Get commit log
run: |
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (%an) [%h](https://github.com/$GITHUB_REPOSITORY/commit/%H)" --no-merges)
else
CHANGELOG=$(git log --pretty=format:"- %s (%an) [%h](https://github.com/$GITHUB_REPOSITORY/commit/%H)" --no-merges ${PREV_TAG}..HEAD)
fi
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
echo "$CHANGELOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Commit and Push Changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "generate registry v${{ env.REGISTRY_VERSION }} [no ci]" || echo "No changes to commit"
git push
- name: Create tag
run: |
git tag "v${{ env.REGISTRY_VERSION }}"
git push origin "v${{ env.REGISTRY_VERSION }}"
IFS='.' read -r MAJOR MINOR PATCH <<< "${{ env.REGISTRY_VERSION }}"
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
echo "MINOR=$MINOR" >> $GITHUB_ENV
echo "PATCH=$PATCH" >> $GITHUB_ENV
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{ env.REGISTRY_VERSION }}"
release_name: "v${{ env.REGISTRY_VERSION }}"
body: |
### Networks Registry v${{ env.REGISTRY_VERSION }}
- ${{ env.REGISTRY_ROOT_URL }}/TheGraphNetworksRegistry.json
- ${{ env.REGISTRY_ROOT_URL }}/TheGraphNetworksRegistry_v${{ env.MAJOR }}_x_x.json
- ${{ env.REGISTRY_ROOT_URL }}/TheGraphNetworksRegistry_v${{ env.MAJOR }}_${{ env.MINOR }}_x.json
- ${{ env.REGISTRY_ROOT_URL }}/TheGraphNetworksRegistry_v${{ env.MAJOR }}_${{ env.MINOR }}_${{ env.PATCH }}.json
### Schema v${{ env.MAJOR }}.${{ env.MINOR }}
- ${{ env.REGISTRY_ROOT_URL }}/TheGraphNetworksRegistrySchema_v${{ env.MAJOR }}_${{ env.MINOR }}.json
### Changes
${{ env.CHANGELOG }}
env:
THEGRAPH_STUDIO_KEY: ${{ secrets.THEGRAPH_STUDIO_KEY }}
REGISTRY_ROOT_URL: ${{ vars.REGISTRY_ROOT_URL }}