-
Notifications
You must be signed in to change notification settings - Fork 35
217 lines (197 loc) · 8.65 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: release
run-name: 'release: ${{ github.ref_name }}'
on:
workflow_dispatch:
inputs:
next-version:
type: string
description: Semantic version of the new release to publish
required: true
permissions:
id-token: write
contents: write
jobs:
get-current-state:
name: Get the current release state
runs-on: ubuntu-latest
env:
NEXT_VERSION: "${{ inputs.next-version }}"
outputs:
dmg_filename: "Wallet Recovery Wizard-${{ inputs.next-version }}.dmg"
exe_filename: "Wallet Recovery Wizard-Setup-${{ inputs.next-version }}.exe"
deb_filename: "Wallet Recovery Wizard-Linux-${{ inputs.next-version }}.deb"
steps:
- name: Verify the target branch
if: github.ref != 'refs/heads/master'
run: |
echo "This workflow should only run from the master branch"
exit 1
- run: |
if [[ ${{ env.NEXT_VERSION }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "The format of the next version is valid."
else
echo "Invalid format for the next version. Please provide a semantic release version number."
exit 1
fi
- name: Check if a release already exists for that version
run: |
current_release=$(
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/BitGo/wallet-recovery-wizard/releases/tags/v${{ env.NEXT_VERSION }}
)
current_release_name=$(echo "$current_release" | jq ".name // empty")
if [[ -n "$current_release_name" ]]; then
echo "A release already exists for version ${{ env.NEXT_VERSION }}."
exit 1
fi
mac-build:
name: Create Mac release
runs-on: macos-12
needs:
- get-current-state
env:
DMG_FILENAME: "${{ needs.get-current-state.outputs.dmg_filename }}"
NEXT_VERSION: "${{ inputs.next-version }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'npm'
- run: |
sed -i -e 's/0.0.0-placeholder-version/${{ env.NEXT_VERSION }}/g' "package.json"
sed -i -e 's/0.0.0-placeholder-version/${{ env.NEXT_VERSION }}/g' "package-lock.json"
- run: npm ci
- run: npm run build
- uses: actions/upload-artifact@v4
with:
name: "${{ env.DMG_FILENAME }}"
path: "release/${{ env.NEXT_VERSION }}/${{ env.DMG_FILENAME }}"
if-no-files-found: "error"
windows-linux-build:
name: Create Windows and Linux release
runs-on: ubuntu-latest
needs:
- get-current-state
env:
EXE_FILENAME: "${{ needs.get-current-state.outputs.exe_filename }}"
DEB_FILENAME: "${{ needs.get-current-state.outputs.deb_filename }}"
NEXT_VERSION: "${{ inputs.next-version }}"
container:
image: docker.io/electronuserland/builder:16-wine@sha256:a067f3efbc83d41f8a92f4bb347803e11ae0b29204520497edb3d34522d8d458
steps:
- uses: actions/checkout@v4
- run: |
sed -i -e 's/0.0.0-placeholder-version/${{ env.NEXT_VERSION }}/g' "package.json"
sed -i -e 's/0.0.0-placeholder-version/${{ env.NEXT_VERSION }}/g' "package-lock.json"
- run: npm ci
- run: npm run build -- -wl
- uses: actions/upload-artifact@v4
with:
name: "${{ env.EXE_FILENAME }}"
path: "release/${{ env.NEXT_VERSION }}/${{ env.EXE_FILENAME }}"
if-no-files-found: "error"
- uses: actions/upload-artifact@v4
with:
name: "${{ env.DEB_FILENAME }}"
path: "release/${{ env.NEXT_VERSION }}/${{ env.DEB_FILENAME }}"
if-no-files-found: "error"
create-new-release:
name: Create a new GitHub release
runs-on: ubuntu-latest
needs:
- get-current-state
- mac-build
- windows-linux-build
env:
DMG_FILENAME: "${{ needs.get-current-state.outputs.dmg_filename }}"
EXE_FILENAME: "${{ needs.get-current-state.outputs.exe_filename }}"
DEB_FILENAME: "${{ needs.get-current-state.outputs.deb_filename }}"
NEXT_VERSION: "${{ inputs.next-version }}"
steps:
- uses: actions/download-artifact@v4
with:
# We don't want to download the artifacts to separate directories,
# we want to download them to the same directory instead.
merge-multiple: true
- run: |
ls -la
sha256sum "${{ env.DMG_FILENAME }}" > "${{ env.DMG_FILENAME }}.sha256sum"
sha256sum "${{ env.DEB_FILENAME }}" > "${{ env.DEB_FILENAME }}.sha256sum"
sha256sum "${{ env.EXE_FILENAME }}" > "${{ env.EXE_FILENAME }}.sha256sum"
- name: Get the ID of the new release
id: get-new-release-id
run: |
new_release=$(curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/BitGo/wallet-recovery-wizard/releases \
-d '{"tag_name":"v${{ env.NEXT_VERSION }}","target_commitish":"${{ github.sha }}","name":"v${{ env.NEXT_VERSION }}","draft":true,"generate_release_notes":true}'
)
new_release_id=$(echo "$new_release" | jq ".id")
echo "new_release_id=$new_release_id" >> "$GITHUB_OUTPUT"
echo "new_release_id = $new_release_id"
new_release_url="https://uploads.github.com/repos/BitGo/wallet-recovery-wizard/releases/$new_release_id/assets"
echo "new_release_url=$new_release_url" >> "$GITHUB_OUTPUT"
- name: Add the Mac assets to the release
run: |
target_dmg_filename=$(echo "${{ env.DMG_FILENAME }}" | sed 's/\ /\./g')
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ steps.get-new-release-id.outputs.new_release_url }}?name=$target_dmg_filename" \
--data-binary "@${{ env.DMG_FILENAME }}"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ steps.get-new-release-id.outputs.new_release_url }}?name=$target_dmg_filename.sha256sum" \
--data-binary "@${{ env.DMG_FILENAME }}.sha256sum"
- name: Add the Linux assets to the release
run: |
target_deb_filename=$(echo "${{ env.DEB_FILENAME }}" | sed 's/\ /\./g')
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ steps.get-new-release-id.outputs.new_release_url }}?name=$target_deb_filename" \
--data-binary "@${{ env.DEB_FILENAME }}"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ steps.get-new-release-id.outputs.new_release_url }}?name=$target_deb_filename.sha256sum" \
--data-binary "@${{ env.DEB_FILENAME }}.sha256sum"
- name: Add the Windows assets to the release
run: |
target_exe_filename=$(echo "${{ env.EXE_FILENAME }}" | sed 's/\ /\./g')
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ steps.get-new-release-id.outputs.new_release_url }}?name=$target_exe_filename" \
--data-binary "@${{ env.EXE_FILENAME }}"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-H "Content-Type: application/octet-stream" \
"${{ steps.get-new-release-id.outputs.new_release_url }}?name=$target_exe_filename.sha256sum" \
--data-binary "@${{ env.EXE_FILENAME }}.sha256sum"