|
8 | 8 | jobs: |
9 | 9 |
|
10 | 10 | publish: |
11 | | - name: Publishing for ${{ matrix.job.os }} |
| 11 | + name: Publishing for ${{ matrix.job.os-name }}-${{ matrix.job.architecture }} |
12 | 12 | runs-on: ${{ matrix.job.os }} |
13 | 13 | permissions: |
14 | 14 | contents: write |
15 | 15 | strategy: |
| 16 | + fail-fast: false |
16 | 17 | matrix: |
17 | 18 | rust: [stable] |
18 | 19 | job: |
19 | 20 | - os: macos-latest |
20 | 21 | os-name: macos |
21 | 22 | target: x86_64-apple-darwin |
22 | 23 | architecture: x86_64 |
23 | | - binary-postfix: "" |
24 | | - use-cross: false |
25 | 24 | - os: macos-latest |
26 | 25 | os-name: macos |
27 | 26 | target: aarch64-apple-darwin |
28 | 27 | architecture: arm64 |
29 | | - binary-postfix: "" |
30 | | - use-cross: false |
31 | 28 | - os: ubuntu-latest |
32 | 29 | os-name: linux |
33 | 30 | target: x86_64-unknown-linux-gnu |
34 | 31 | architecture: x86_64 |
35 | | - binary-postfix: "" |
36 | | - use-cross: false |
37 | 32 | - os: windows-latest |
38 | 33 | os-name: windows |
39 | 34 | target: x86_64-pc-windows-msvc |
40 | 35 | architecture: x86_64 |
41 | | - binary-postfix: ".exe" |
42 | | - use-cross: false |
43 | 36 | - os: ubuntu-latest |
44 | 37 | os-name: linux |
45 | 38 | target: aarch64-unknown-linux-gnu |
46 | 39 | architecture: arm64 |
47 | | - binary-postfix: "" |
48 | | - use-cross: true |
49 | 40 | - os: ubuntu-latest |
50 | 41 | os-name: linux |
51 | 42 | target: i686-unknown-linux-gnu |
52 | 43 | architecture: i686 |
53 | | - binary-postfix: "" |
54 | | - use-cross: true |
55 | 44 |
|
56 | 45 | steps: |
57 | 46 | - name: Checkout repository |
58 | 47 | uses: actions/checkout@v4 |
59 | 48 | - name: Install Rust toolchain |
60 | | - uses: actions-rs/toolchain@v1 |
| 49 | + uses: dtolnay/rust-toolchain@stable |
61 | 50 | with: |
62 | 51 | toolchain: ${{ matrix.rust }} |
63 | 52 | target: ${{ matrix.job.target }} |
64 | | - profile: minimal |
65 | | - override: true |
66 | | - - uses: Swatinem/rust-cache@v2 |
67 | | - - name: Cargo build |
68 | | - uses: actions-rs/cargo@v1 |
| 53 | + - name: Install cross |
| 54 | + uses: taiki-e/install-action@v2 |
69 | 55 | with: |
70 | | - command: build |
71 | | - use-cross: ${{ matrix.job.use-cross }} |
72 | | - toolchain: ${{ matrix.rust }} |
73 | | - args: --release --target ${{ matrix.job.target }} |
| 56 | + tool: cross |
| 57 | + - name: Build release binary |
| 58 | + run: cross build --locked --release --target ${{ matrix.job.target }} |
74 | 59 |
|
75 | 60 | - name: install strip command |
| 61 | + if: matrix.job.target == 'aarch64-unknown-linux-gnu' |
76 | 62 | shell: bash |
77 | 63 | run: | |
78 | | - if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then |
79 | | - sudo apt update |
80 | | - sudo apt-get install -y binutils-aarch64-linux-gnu |
81 | | - fi |
| 64 | + sudo apt update |
| 65 | + sudo apt-get install -y binutils-aarch64-linux-gnu |
82 | 66 | - name: Packaging final binary |
83 | 67 | shell: bash |
84 | 68 | run: | |
85 | | - cd target/${{ matrix.job.target }}/release |
| 69 | + BINARY=target/${{ matrix.job.target }}/release/rust-gh-example |
| 70 | + if [[ ${{ runner.os }} == 'Windows' ]]; then |
| 71 | + BINARY=$BINARY.exe |
| 72 | + fi |
86 | 73 |
|
87 | 74 | ####### reduce binary size by removing debug symbols ####### |
88 | | - BINARY_NAME=rust-gh-example${{ matrix.job.binary-postfix }} |
89 | 75 | if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then |
90 | 76 | GCC_PREFIX="aarch64-linux-gnu-" |
91 | 77 | else |
92 | 78 | GCC_PREFIX="" |
93 | 79 | fi |
94 | | - "$GCC_PREFIX"strip $BINARY_NAME |
| 80 | + "$GCC_PREFIX"strip $BINARY |
95 | 81 |
|
96 | 82 | ########## create tar.gz ########## |
| 83 | + mkdir assets |
97 | 84 | RELEASE_NAME=rust-gh-example-${GITHUB_REF/refs\/tags\//}-${{ matrix.job.os-name }}-${{ matrix.job.architecture }} |
98 | | - tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME |
| 85 | + tar czvf assets/$RELEASE_NAME.tar.gz $BINARY |
99 | 86 |
|
100 | 87 | ########## create sha256 ########## |
101 | 88 | if [[ ${{ runner.os }} == 'Windows' ]]; then |
102 | | - certutil -hashfile $RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME.sha256 |
| 89 | + certutil -hashfile assets/$RELEASE_NAME.tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > assets/$RELEASE_NAME.sha256 |
103 | 90 | else |
104 | | - shasum -a 256 $RELEASE_NAME.tar.gz > $RELEASE_NAME.sha256 |
| 91 | + shasum -a 256 assets/$RELEASE_NAME.tar.gz > assets/$RELEASE_NAME.sha256 |
105 | 92 | fi |
106 | 93 | - name: Releasing assets |
107 | 94 | uses: softprops/action-gh-release@v2 |
108 | 95 | with: |
109 | | - files: | |
110 | | - target/${{ matrix.job.target }}/release/rust-gh-example-*.tar.gz |
111 | | - target/${{ matrix.job.target }}/release/rust-gh-example-*.sha256 |
| 96 | + files: assets/* |
112 | 97 | env: |
113 | 98 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
114 | 99 |
|
|
0 commit comments