-
Notifications
You must be signed in to change notification settings - Fork 9
180 lines (168 loc) · 6.99 KB
/
release.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Release
on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]
jobs:
GetVersion:
runs-on: ubuntu-latest
timeout-minutes: 60
outputs:
version: ${{ steps.version.outputs.value }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Halt release if CI failed
run: exit 1
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
- id: version
name: Get version
run: echo "::set-output name=value::$(cat VERSION | grep v)"
- name: Check if tag Exists
id: tag_check
shell: bash -ex {0}
run: |
GET_API_URL="https://api.github.com/repos/${{github.repository}}/git/ref/tags/${{env.RELEASE_VERSION}}"
http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \
-H "Authorization: token ${GITHUB_TOKEN}")
if [ "$http_status_code" -ne "404" ] ; then
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Github-release:
name: Create Release
runs-on: ubuntu-latest
needs:
- GetVersion
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: print version with needs
run: echo ${{ needs.GetVersion.outputs.version }}
- id: changelog
name: "Generate release changelog"
uses: heinrichreimer/github-changelog-generator-action@v2.3
with:
unreleasedOnly: true
unreleasedLabel: ${{ needs.GetVersion.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.GetVersion.outputs.version }}
release_name: Release ${{ needs.GetVersion.outputs.version }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
Deploy-Built-Artifacts:
strategy:
matrix:
package:
- hello-world,hello
- simple-storage,simple-storage
- json-rpc,jsonrpc
- subgraph-query,subgraph
- common-interface, common-interface
language:
- interface
- assemblyscript
- rust
needs:
- GetVersion
runs-on: ubuntu-latest
timeout-minutes: 60
env:
CI: false
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm
- name: Setup Node.js
uses: actions/setup-node@master
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-deployments-v1
restore-keys: |
${{ runner.os }}-yarn-deployments-
# Install packages
- name: Install pinata cli
run: yarn global add pinata-upload-cli
- name: Install ethers cli
run: yarn global add @ethersproject/cli
# Get Package Metadata
- id: package
name: Get Package Metadata
run: |
echo ::set-output name=name::$(node ./scripts/release/getPackageData.js ${{ matrix.package }} ${{ matrix.language }} 0)
echo ::set-output name=uri::$(node ./scripts/release/getPackageData.js ${{ matrix.package }} ${{ matrix.language }} 1)
# Setup Pinata
- name: Setup Pinata
run: pinata-cli -a ${{ secrets.PINATA_API_KEY }}
# Fetch Built Wrappers
- id: shouldRun
name: Check if the step should run or not
run: 'echo ::set-output name=value::$(node ./scripts/release/shouldRun.js ${{ matrix.demo }} ${{ matrix.language }})'
- name: create builds
run: mkdir ./builds # fails if dir already exists but that's okay
continue-on-error: true
- uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: ci.yml
workflow_conclusion: success
branch: main
event: push
name: ${{ steps.package.outputs.name }}-${{ matrix.language }}-build-artifact
path: ./${{ steps.package.outputs.name }}-${{ matrix.language }}-build-artifact
if: ${{ (steps.shouldRun.outputs.value == 'true') }}
- name: create deployments
run: mkdir ./deployments # fails if dir already exists but that's okay
continue-on-error: true
# Deploy wrappers to IPFS
- name: Deploy current wrapper to IPFS
run: pinata-cli -u ./${{ steps.package.outputs.name }}-${{ matrix.language }}-build-artifact > ./deployments/${{ steps.package.outputs.name }}-${{ matrix.language }}.ipfs.txt
if: ${{ (steps.shouldRun.outputs.value == 'true') }}
- id: ipfs
name: Fetch IPFS CID for current wrapper
run: echo ::set-output name=value::$(node ./scripts/release/getIpfsCid.js "$(cat ./deployments/${{ steps.package.outputs.name }}-${{ matrix.language }}.ipfs.txt)")
if: ${{ (steps.shouldRun.outputs.value == 'true') }}
# Deploy wrappers to ENS
- id: ensExists
name: Check if ens uri exists
run: 'echo ::set-output name=value::$(node ./scripts/release/checkEnsExists.js "$(ethers-ens lookup ${{ steps.package.outputs.uri }} --rpc https://goerli.infura.io/v3/${{ secrets.INFURA_KEY }})")'
if: ${{ (steps.shouldRun.outputs.value == 'true') }}
- name: Create ens subdomain uri
uses: Wandalen/wretry.action@v1.0.11
with:
command: ethers-ens set-subnode "${{ steps.package.outputs.uri }}" --account ${{ secrets.PRIVATE_KEY }} --rpc https://goerli.infura.io/v3/${{ secrets.INFURA_KEY }} --yes --wait
attempt_limit: 3
attempt_delay: 20000
if: ${{ (steps.ensExists.outputs.value == 'false') && (steps.shouldRun.outputs.value == 'true') }}
- name: Set Resolver for created ens subdomain
uses: Wandalen/wretry.action@v1.0.11
with:
command: "ethers-ens set-resolver ${{ steps.package.outputs.uri }} --account ${{ secrets.PRIVATE_KEY }} --rpc https://goerli.infura.io/v3/${{ secrets.INFURA_KEY }} --yes --wait"
attempt_limit: 3
attempt_delay: 20000
if: ${{ (steps.ensExists.outputs.value == 'false') && (steps.shouldRun.outputs.value == 'true') }}
- name: Publish current wrapper to ENS
uses: Wandalen/wretry.action@v1.0.11
with:
command: "ethers-ens set-content ${{ steps.package.outputs.uri }} ${{ steps.ipfs.outputs.value }} --account ${{ secrets.PRIVATE_KEY }} --rpc https://goerli.infura.io/v3/${{ secrets.INFURA_KEY }} --yes --wait"
attempt_limit: 3
attempt_delay: 20000
if: ${{ (steps.shouldRun.outputs.value == 'true') }}