-
Notifications
You must be signed in to change notification settings - Fork 9
397 lines (382 loc) · 15.6 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
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
name: Release
on:
push:
tags:
- "*.*.*"
jobs:
build-python-wheels:
env:
# Note that we want to build only for a single python version
# since we're targeting abi3. Sync changes with setup.cfg and
# the "abi3-pyXX" PyO3 feature in Cargo.toml
CIBW_SKIP: "cp36-* cp37-* cp38-* cp310-* cp311-* pp* *i686 *win32"
CIBW_ARCHS_LINUX: ${{matrix.arch}}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
arch: [x86_64, aarch64]
exclude:
- os: ubuntu-latest
arch: aarch64
- os: macos-latest
arch: aarch64
- os: windows-latest
arch: aarch64
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-python@v5
name: Setup python
with:
python-version: '3.x'
- uses: docker/setup-qemu-action@v3
if: ${{ matrix.arch == 'aarch64' }}
name: Set up QEMU
- name: Install cibuildwheel
run: python -m pip install cibuildwheel setuptools_rust
- name: Build wheels on Linux and macOS
if: runner.os != 'Windows'
run: |
export CIBW_BEFORE_BUILD='pip install setuptools-rust && curl -o /tmp/rustup.sh https://sh.rustup.rs && sh /tmp/rustup.sh -y'
# shellcheck disable=SC2016
export CIBW_ENVIRONMENT='PATH="$HOME"/.cargo/bin:"$PATH"'
if [ "$(uname)" = Darwin ]; then
export MACOSX_DEPLOYMENT_TARGET=10.12
export CIBW_BEFORE_BUILD="$CIBW_BEFORE_BUILD && rustup target add aarch64-apple-darwin x86_64-apple-darwin"
export CIBW_ARCHS_MACOS="universal2"
fi
python -m cibuildwheel --output-dir wheelhouse crates/python
- name: Build wheels on Windows
if: runner.os == 'Windows'
env:
CIBW_BEFORE_BUILD: "python3 -m pip install setuptools_rust"
run: |
python3 -m cibuildwheel --output-dir wheelhouse crates/python
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.arch }}-${{ matrix.os }}
path: ./wheelhouse/*.whl
release-core-docker-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cross
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to docker hub
run: docker login -u fredrikfornwall -p "$DOCKER_ACCESS_TOKEN"
env:
DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Install aarch64 strip
run: sudo apt-get update && sudo apt-get -y install binutils-aarch64-linux-gnu
- name: Build and push docker image
working-directory: crates/core
env:
DOCKER_IMAGE_NAME: fredrikfornwall/advent-of-code
run: |
NEW_VERSION=$(cargo metadata --format-version 1 | jq --raw-output '.packages[0].version')
cross build --release --target aarch64-unknown-linux-musl
cross build --release --target x86_64-unknown-linux-musl
strip -s ../../target/x86_64-unknown-linux-musl/release/advent-of-code
aarch64-linux-gnu-strip -s ../../target/aarch64-unknown-linux-musl/release/advent-of-code
IMAGE_WITH_VERSION=${DOCKER_IMAGE_NAME}:${NEW_VERSION}
IMAGE_WITH_LATEST=${DOCKER_IMAGE_NAME}:latest
mkdir -p target/linux/{arm64,amd64}
cp ../../target/x86_64-unknown-linux-musl/release/advent-of-code target/linux/amd64/
cp ../../target/aarch64-unknown-linux-musl/release/advent-of-code target/linux/arm64/
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag "${IMAGE_WITH_VERSION}" --tag "${IMAGE_WITH_LATEST}" .
release-npm-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
- uses: Homebrew/actions/setup-homebrew@master
- name: Install wasm-opt
run: brew update && brew install binaryen
- name: Publish npm packages
run: |
make install-wasm-bindgen
. "${HOME}"/.cargo/env
make npm-publish
env:
# It needs to be named 'NODE_AUTH_TOKEN' as it's referenced
# by the .npmrc created by setup-node:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
release-rust-crate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Login to cargo
run: cargo login "${CRATES_API_TOKEN}"
env:
CRATES_API_TOKEN: ${{secrets.CRATES_API_TOKEN}}
- name: Publish svgplot crate
run: cd crates/svgplot && cargo publish
- name: Publish core crate
run: cd crates/core && cargo publish
release-pypi-package:
needs: [build-python-wheels]
runs-on: ubuntu-latest
steps:
- name: Download built wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist
- name: List files
run: ls -lha dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
build-jni-libraries:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
if: runner.os == 'macOS'
- name: List sdks
run: xcodebuild -showsdks
if: runner.os == 'macOS'
- run: cargo install cross
if: runner.os == 'Linux'
- name: Install aarch64-apple-darwin rust target
run: rustup target add aarch64-apple-darwin
if: runner.os == 'macOS'
- name: Install aarch64 strip
run: sudo apt-get update && sudo apt-get -y install binutils-aarch64-linux-gnu
if: runner.os == 'Linux'
- name: Build JNI libraries
working-directory: crates/java
run: ./build-jni-libs.sh
shell: bash
- name: Test java
working-directory: crates/java/java-src
run: gradle test
- uses: actions/upload-artifact@v4
with:
name: jnilibs-${{ matrix.os }}
path: ./crates/java/java-src/src/main/resources/*
build-and-upload-man-page:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Homebrew/actions/setup-homebrew@master
- run: brew install pandoc
- run: make man-page
- uses: actions/upload-artifact@v4
with:
name: man-page
path: target/man/advent-of-code.1
build-and-upload-linux-brew-binaries:
runs-on: ubuntu-latest
needs: [build-and-upload-man-page]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cross
- name: Install aarch64 strip
run: sudo apt-get update && sudo apt-get -y install binutils-aarch64-linux-gnu
- uses: actions/download-artifact@v4
with:
name: man-page
path: crates/core
- run: |
cross build --release --target aarch64-unknown-linux-musl
cross build --release --target x86_64-unknown-linux-musl
strip -s ../../target/x86_64-unknown-linux-musl/release/advent-of-code
aarch64-linux-gnu-strip -s ../../target/aarch64-unknown-linux-musl/release/advent-of-code
cp advent-of-code.1 ../../target/x86_64-unknown-linux-musl/release
cp advent-of-code.1 ../../target/aarch64-unknown-linux-musl/release
cd ../../target/x86_64-unknown-linux-musl/release && tar cfJ advent-of-code-linux-x86_64.tar.xz advent-of-code advent-of-code.1 && mv ./*.tar.xz ../../../
cd ../../aarch64-unknown-linux-musl/release && tar cfJ advent-of-code-linux-aarch64.tar.xz advent-of-code advent-of-code.1 && mv ./*.tar.xz ../../../
working-directory: crates/core
- name: Upload Linux x86_64 binary
uses: actions/upload-artifact@v4
with:
name: linux-x86_64-binary
path: advent-of-code-linux-x86_64.tar.xz
- name: Upload Linux aarch64 binary
uses: actions/upload-artifact@v4
with:
name: linux-aarch64-binary
path: advent-of-code-linux-aarch64.tar.xz
build-and-upload-mac-brew-binaries:
runs-on: macos-latest
needs: [build-and-upload-man-page]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/download-artifact@v4
with:
name: man-page
path: crates/core
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- run: rustup target add aarch64-apple-darwin
- run: |
cargo build --release
SDKROOT=$(xcrun -sdk "$MACOS_SDK" --show-sdk-path) MACOSX_DEPLOYMENT_TARGET=10.12 cargo build --release --target=aarch64-apple-darwin
strip ../../target/release/advent-of-code
strip ../../target/aarch64-apple-darwin/release/advent-of-code
cp advent-of-code.1 ../../target/release
cp advent-of-code.1 ../../target/aarch64-apple-darwin/release
cd ../../target/release && tar cfJ advent-of-code-mac-x86_64.tar.xz advent-of-code advent-of-code.1 && mv advent-of-code-mac-x86_64.tar.xz ../../
cd ../aarch64-apple-darwin/release && tar cfJ advent-of-code-mac-aarch64.tar.xz advent-of-code advent-of-code.1 && mv advent-of-code-mac-aarch64.tar.xz ../../../
working-directory: crates/core
- name: Upload mac x86_64 binary
uses: actions/upload-artifact@v4
with:
name: mac-x86_64-binary
path: advent-of-code-mac-x86_64.tar.xz
- name: Upload mac aarch64 binary
uses: actions/upload-artifact@v4
with:
name: mac-aarch64-binary
path: advent-of-code-mac-aarch64.tar.xz
publish-to-maven-central:
needs: [build-jni-libraries]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Download JNI libraries
uses: actions/download-artifact@v4
with:
pattern: jnilibs-*
merge-multiple: true
path: crates/java/java-src/src/main/resources/
- name: Publish to Maven Central
working-directory: crates/java/java-src
run: |
echo "${{ secrets.OSSRH_GPG_SECRING_BASE64 }}" | base64 -d > secring.gpg
gradle --info \
-PsonatypeUsername=${{ secrets.SONATYPE_USERNAME }} \
-PsonatypePassword=${{ secrets.SONATYPE_PASSWORD }} \
-Psigning.keyId=6D8D0AE7 \
-Psigning.password=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} \
-Psigning.secretKeyRingFile=secring.gpg \
publishToSonatype \
closeAndReleaseSonatypeStagingRepository
github-release:
needs: [build-and-upload-linux-brew-binaries, build-and-upload-mac-brew-binaries]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: mac-x86_64-binary
- uses: actions/download-artifact@v4
with:
name: mac-aarch64-binary
- uses: actions/download-artifact@v4
with:
name: linux-x86_64-binary
- uses: actions/download-artifact@v4
with:
name: linux-aarch64-binary
- uses: softprops/action-gh-release@v2
with:
files: |
advent-of-code-linux-aarch64.tar.xz
advent-of-code-linux-x86_64.tar.xz
advent-of-code-mac-aarch64.tar.xz
advent-of-code-mac-x86_64.tar.xz
publish-homebrew:
runs-on: ubuntu-latest
needs: [github-release]
steps:
- name: Check out source code
uses: actions/checkout@v4
- run: |
NEW_VERSION=$(./.github/workflows/current-version)
curl -X POST -H "Authorization: Bearer ${{ secrets.HOMEBREW_TAP_GITHUB_ACCESS_TOKEN }} " -H "Accept:application/vnd.github" "https://api.github.com/repos/fornwall/homebrew-tap/actions/workflows/publish.yml/dispatches" -d "{\"ref\":\"main\", \"inputs\":{\"formula\":\"advent-of-code\",\"version\":\"$NEW_VERSION\"}}"
publish-grpc-server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cross
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to docker hub
run: docker login -u fredrikfornwall -p "$DOCKER_ACCESS_TOKEN"
env:
DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Install aarch64 strip
run: sudo apt-get update && sudo apt-get -y install binutils-aarch64-linux-gnu
- name: Build and push docker image
working-directory: crates/grpc-server
env:
DOCKER_IMAGE_NAME: fredrikfornwall/advent-of-code-grpc-server
run: |
NEW_VERSION=$(cargo metadata --format-version 1 | jq --raw-output '.packages[0].version')
cross build --release --target aarch64-unknown-linux-musl
cross build --release --target x86_64-unknown-linux-musl
strip -s ../../target/x86_64-unknown-linux-musl/release/advent-of-code-grpc-server
aarch64-linux-gnu-strip -s ../../target/aarch64-unknown-linux-musl/release/advent-of-code-grpc-server
IMAGE_WITH_VERSION=${DOCKER_IMAGE_NAME}:${NEW_VERSION}
IMAGE_WITH_LATEST=${DOCKER_IMAGE_NAME}:latest
mkdir -p target/linux/{arm64,amd64}
cp ../../target/x86_64-unknown-linux-musl/release/advent-of-code-grpc-server target/linux/amd64/
cp ../../target/aarch64-unknown-linux-musl/release/advent-of-code-grpc-server target/linux/arm64/
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag "${IMAGE_WITH_VERSION}" --tag "${IMAGE_WITH_LATEST}" .
publish-http-server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cross
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to docker hub
run: docker login -u fredrikfornwall -p "$DOCKER_ACCESS_TOKEN"
env:
DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Install aarch64 strip
run: sudo apt-get update && sudo apt-get -y install binutils-aarch64-linux-gnu
- name: Build and push docker image
working-directory: crates/http-server
env:
DOCKER_IMAGE_NAME: fredrikfornwall/advent-of-code-http-server
run: |
NEW_VERSION=$(cargo metadata --format-version 1 | jq --raw-output '.packages[0].version')
cross build --release --target aarch64-unknown-linux-musl
cross build --release --target x86_64-unknown-linux-musl
strip -s ../../target/x86_64-unknown-linux-musl/release/advent-of-code-server
aarch64-linux-gnu-strip -s ../../target/aarch64-unknown-linux-musl/release/advent-of-code-server
IMAGE_WITH_VERSION=${DOCKER_IMAGE_NAME}:${NEW_VERSION}
IMAGE_WITH_LATEST=${DOCKER_IMAGE_NAME}:latest
mkdir -p target/linux/{arm64,amd64}
cp ../../target/x86_64-unknown-linux-musl/release/advent-of-code-server target/linux/amd64/
cp ../../target/aarch64-unknown-linux-musl/release/advent-of-code-server target/linux/arm64/
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag "${IMAGE_WITH_VERSION}" --tag "${IMAGE_WITH_LATEST}" .