-
Notifications
You must be signed in to change notification settings - Fork 62
308 lines (293 loc) · 10.8 KB
/
release.yaml
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
name: release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/lint
parse_tag:
runs-on: ubuntu-22.04
outputs:
is_stable_version: ${{ steps.parse.outputs.is_stable_version }}
version: ${{ steps.parse.outputs.version }}
steps:
- id: parse
run: |
echo "is_stable_version=$([[ $GITHUB_REF_NAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && echo true || echo false)" >> $GITHUB_OUTPUT
echo "version=${GITHUB_REF_NAME:1}" >> $GITHUB_OUTPUT
pypi-build:
needs: lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade poetry
poetry install
- run: poetry build
- uses: actions/upload-artifact@v4
with:
name: pypi
path: dist/*
if-no-files-found: error
pypi-test:
needs: pypi-build
strategy:
matrix:
python: ['3.10', '3.11', '3.12']
# macos-13 is amd64, macos-15 is arm64
# skipping macos-13 here because newer versions of torch aren't being built for amd64 macOS anymore
# builds for amd64 macOS are being tested during brew release
os: [ubuntu-22.04, macos-15, windows-2022]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- run: python -m pip install --upgrade pip
- uses: actions/download-artifact@v4
with:
name: pypi
path: dist/
- run: pip install --extra-index-url https://download.pytorch.org/whl/cpu dist/rclip-*.whl
if: startsWith(matrix.os, 'ubuntu-')
shell: bash
- run: pip install dist/rclip-*.whl
if: ${{ !startsWith(matrix.os, 'ubuntu-') }}
shell: bash
- uses: ./.github/actions/test-system-rclip
with:
python: ${{ matrix.python }}
pypi-release:
needs: pypi-test
runs-on: ubuntu-22.04
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: pypi
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
brew:
# the Formula references the rclip package published to PyPI
needs: [parse_tag, pypi-release]
if: needs.parse_tag.outputs.is_stable_version == 'true'
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade poetry
poetry install
- name: Setup git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Zhi Bot"
- run: make release-brew
env:
GITHUB_TOKEN: ${{ secrets.ZHIBOT_GITHUB_TOKEN }}
snap-build:
needs: pypi-build
strategy:
matrix:
include:
- arch: amd64
runner: ubuntu-20.04
- arch: arm64
runner: ubuntu-22.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: canonical/setup-lxd@main
- name: Download built wheel
uses: actions/download-artifact@v4
with:
name: pypi
path: dist/
- name: Copy wheel to snapcraft local dir
run: |
mkdir snap/local
cp -v dist/rclip-*.tar.gz snap/local
- run: sudo snap install snapcraft --classic
- run: snapcraft --use-lxd --build-for ${{ matrix.arch }}
- uses: actions/upload-artifact@v4
with:
name: snap-${{ matrix.arch }}
path: rclip_*.snap
if-no-files-found: error
snap-test:
needs: snap-build
strategy:
matrix:
include:
- arch: amd64
runner: ubuntu-20.04
- arch: arm64
runner: ubuntu-22.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: snap-${{ matrix.arch }}
- run: sudo snap install rclip_*_${{ matrix.arch }}.snap --dangerous
- uses: ./.github/actions/test-system-rclip
snap-release:
needs: [snap-test, parse_tag]
runs-on: ubuntu-20.04
steps:
- run: sudo snap install snapcraft --classic
- uses: actions/download-artifact@v4
with:
pattern: snap-*
merge-multiple: true
- name: Upload snaps to the beta channel
run: |
for snap in *.snap; do
snapcraft upload --release=beta "$snap"
done
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_LOGIN }}
- name: Promote snaps to the stable channel
if: needs.parse_tag.outputs.is_stable_version == 'true'
run: snapcraft promote --from-channel=beta --to-channel=stable --yes rclip
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_LOGIN }}
appimage-build:
needs: [lint, parse_tag]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install poetry
run: |
python -m pip install --upgrade pip
pip install --upgrade poetry
- run: sudo apt-get install -y fuse
- name: Install appimage-builder
run: |
wget -O appimage-builder-x86_64.AppImage https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage
chmod +x appimage-builder-x86_64.AppImage
sudo mv appimage-builder-x86_64.AppImage /usr/local/bin/appimage-builder
- name: Build AppImage
env:
APP_VERSION: ${{ needs.parse_tag.outputs.version }}
run: poetry run appimage-builder --skip-tests --recipe ./release-utils/appimage/appimage-builder.yml
- uses: actions/upload-artifact@v4
with:
name: appimage
path: rclip-*.AppImage
if-no-files-found: error
appimage-test:
needs: appimage-build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install -y fuse
- uses: actions/download-artifact@v4
with:
name: appimage
- name: Install AppImage
run: |
chmod +x rclip-*.AppImage
sudo mv rclip-*.AppImage /usr/local/bin/rclip
- uses: ./.github/actions/test-system-rclip
windows-build:
needs: [lint, parse_tag]
if: needs.parse_tag.outputs.is_stable_version == 'true'
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade poetry
poetry install
poetry run pip install pyinstaller==6.10.0
- run: make build-windows
- name: Install Advinst
uses: caphyon/advinst-github-action@main
with:
advinst-version: '21.1'
advinst-enable-automation: 'true'
- run: |
& ./release-utils/windows/build-msi.ps1 "${{ needs.parse_tag.outputs.version }}"
mv build-msi/rclip-SetupFiles/rclip.msi build-msi/rclip-SetupFiles/rclip-${{ needs.parse_tag.outputs.version }}.msi
- name: Sign MSI
run: |
mkdir signed
Invoke-WebRequest -URI https://ee2cc1f8.rocketcdn.me/wp-content/uploads/2023/11/CodeSignTool-v1.2.7-windows.zip -OutFile CodeSignTool.zip
if ( ( Get-FileHash -Algorithm SHA256 CodeSignTool.zip ).Hash -ne 'AC9CDBFF6D482DBC1107ABC8789570F57ECF85773332BBA466CB3E00CE0BB841' ) { throw 'hash does not match' }
Expand-Archive -Path CodeSignTool.zip -DestinationPath .
cd CodeSignTool-v1.2.7-windows
& ./CodeSignTool.bat sign -input_file_path="${env:GITHUB_WORKSPACE}/build-msi/rclip-SetupFiles/rclip-${{ needs.parse_tag.outputs.version }}.msi" -username=${{ secrets.WINDOWS_SIGNING_USERNAME }} -credential_id='${{ secrets.WINDOWS_SIGNING_CREDENTIAL_ID }}' -password='${{ secrets.WINDOWS_SIGNING_PASSWORD }}' -totp_secret='${{ secrets.WINDOWS_SIGNING_TOTP_SECRET }}' -output_dir_path="${env:GITHUB_WORKSPACE}/signed"
- uses: actions/upload-artifact@v4
with:
name: windows
path: signed/rclip-*.msi
if-no-files-found: error
windows-test:
needs: [parse_tag, windows-build]
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: windows
- name: Install MSI
run: Start-Process msiexec.exe -Wait -ArgumentList '/i rclip-${{ needs.parse_tag.outputs.version }}.msi /quiet'
- uses: ./.github/actions/test-system-rclip
create_release:
needs: [parse_tag, pypi-release, snap-release, appimage-test, windows-test]
# the windows job doesn't run for pre-releases, but we need to create a release for pre-releases too
if: ${{ !cancelled() }}
runs-on: ubuntu-22.04
steps:
# if any of the needs jobs fail, we don't want to create a release
# this is needed because of `if: ${{ !cancelled() }}` above
- if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Rename snaps for GitHub releases page
run: |
for snap in artifacts/snap-*/*.snap; do
mv "$snap" "${snap//_/-}"
done
- name: Rename AppImage for GitHub releases page
run: mv artifacts/appimage/rclip-${{ needs.parse_tag.outputs.version }}-x86_64.AppImage artifacts/appimage/rclip-${{ needs.parse_tag.outputs.version }}-amd64.AppImage
- name: Generate Changelog
run: |
git fetch --unshallow
PREVIOUS_TAG="$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))"
git --no-pager log --pretty="format:- %s" $PREVIOUS_TAG..$GITHUB_REF_NAME > release_changelog.md
cat release_changelog.md
- name: Create Release
uses: ncipollo/release-action@v1
with:
name: ${{ github.ref_name }}
artifacts: artifacts/pypi/rclip-*,artifacts/snap-amd64/rclip-*.snap,artifacts/snap-arm64/rclip-*.snap,artifacts/appimage/rclip-*.AppImage,artifacts/windows/rclip-*.msi
bodyFile: release_changelog.md
prerelease: ${{ needs.parse_tag.outputs.is_stable_version == 'false' }}
token: ${{ secrets.GITHUB_TOKEN }}