-
Notifications
You must be signed in to change notification settings - Fork 7
88 lines (83 loc) · 2.71 KB
/
cross-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
name: Cross Release
on:
workflow_dispatch:
jobs:
extract-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Export Crate Package Version
run: echo "VERSION=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version')" >> $GITHUB_OUTPUT
id: export
outputs:
VERSION: ${{ steps.export.outputs.VERSION }}
build:
name: build release
strategy:
matrix:
arch:
[
aarch64-unknown-linux-gnu,
x86_64-unknown-linux-gnu,
x86_64-apple-darwin,
aarch64-apple-darwin,
x86_64-pc-windows-gnu,
]
include:
- arch: aarch64-unknown-linux-gnu
platform: ubuntu-20.04
profile: maxperf
- arch: x86_64-unknown-linux-gnu
platform: ubuntu-20.04
profile: maxperf
- arch: x86_64-apple-darwin
platform: macos-latest
profile: maxperf
- arch: aarch64-apple-darwin
platform: macos-latest
profile: maxperf
- arch: x86_64-pc-windows-gnu
platform: ubuntu-20.04
profile: maxperf
runs-on: ${{ matrix.platform }}
needs: extract-version
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
- run: rustup update stable
- run: rustup target add ${{ matrix.arch }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Apple M1 setup
if: ${{ matrix.job.target == 'aarch64-apple-darwin' }}
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Build for ${{ matrix.arch }}
run: |
cargo install cross
env PROFILE=${{ matrix.profile }} make build-${{ matrix.arch }}
- name: Move cross-compiled binary
if: matrix.arch != 'x86_64-pc-windows-gnu'
run: |
mkdir artifacts
mv target/${{ matrix.arch }}/${{ matrix.profile }}/* ./artifacts
- name: Create artifacts
run: tar --directory=artifacts -czf release-${{ env.VERSION }}-${{ matrix.arch }}.tar.gz $(ls -U artifacts/ | head -1)
shell: bash
release:
name: Release on Github
runs-on: ubuntu-latest
permissions:
contents: write
needs: [build, extract-version]
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
- uses: ncipollo/release-action@v1
with:
artifacts: "artifacts/*"
tag: v${{ env.VERSION }}