77
88jobs :
99 publish :
10- name : Publishing for ${{ matrix.os }}
11- runs-on : ${{ matrix.os }}
10+ name : Publishing for ${{ matrix.job. os }}
11+ runs-on : ${{ matrix.job. os }}
1212 strategy :
1313 matrix :
14- os : [macos-latest, ubuntu-latest, windows-latest]
1514 rust : [stable]
16- include :
15+ job :
1716 - os : macos-latest
18- artifact_prefix : macos
17+ os-name : macos
1918 target : x86_64-apple-darwin
20- binary_postfix : " "
19+ architecture : x86_64
20+ binary-postfix : " "
21+ use-cross : false
2122 - os : ubuntu-latest
22- artifact_prefix : linux
23+ os-name : linux
2324 target : x86_64-unknown-linux-gnu
24- binary_postfix : " "
25+ architecture : x86_64
26+ binary-postfix : " "
27+ use-cross : false
2528 - os : windows-latest
26- artifact_prefix : windows
29+ os-name : windows
2730 target : x86_64-pc-windows-msvc
28- binary_postfix : " .exe"
31+ architecture : x86_64
32+ binary-postfix : " .exe"
33+ use-cross : false
34+ - os : ubuntu-latest
35+ os-name : linux
36+ target : aarch64-unknown-linux-gnu
37+ architecture : arm64
38+ binary-postfix : " "
39+ use-cross : true
40+ - os : ubuntu-latest
41+ os-name : linux
42+ target : i686-unknown-linux-gnu
43+ architecture : i686
44+ binary-postfix : " "
45+ use-cross : true
46+
2947
3048 steps :
3149 - name : Installing Rust toolchain
@@ -40,27 +58,47 @@ jobs:
4058 uses : actions-rs/cargo@v1
4159 with :
4260 command : build
61+ use-cross : ${{ matrix.job.use-cross }}
4362 toolchain : ${{ matrix.rust }}
44- args : --release --target ${{ matrix.target }}
63+ args : --release --target ${{ matrix.job. target }}
4564
65+ - name : install strip command
66+ shell : bash
67+ run : |
68+ if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then
69+ sudo apt update
70+ sudo apt-get install -y binutils-aarch64-linux-gnu
71+ fi
4672 - name : Packaging final binary
4773 shell : bash
4874 run : |
49- cd target/${{ matrix.target }}/release
50- strip rust-gh-example${{ matrix.binary_postfix }}
51- tar czvf rust-gh-example-${{ matrix.artifact_prefix }}.tar.gz rust-gh-example${{ matrix.binary_postfix }}
75+ cd target/${{ matrix.job.target }}/release
76+
77+ ####### reduce binary size by removing debug symbols #######
78+ BINARY_NAME=rust-gh-example${{ matrix.job.binary-postfix }}
79+ if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then
80+ GCC_PREFIX="aarch64-linux-gnu-"
81+ else
82+ GCC_PREFIX=""
83+ fi
84+ "$GCC_PREFIX"strip $BINARY_NAME
85+
86+ ########## create tar.gz ##########
87+ RELEASE_NAME=rust-gh-example-${GITHUB_REF/refs\/tags\//}-${{ matrix.job.os-name }}-${{ matrix.job.architecture }}
88+ tar czvf $RELEASE_NAME.tar.gz $BINARY_NAME
5289
90+ ########## create sha256 ##########
5391 if [[ ${{ runner.os }} == 'Windows' ]]; then
54- certutil -hashfile rust-gh-example-${{ matrix.artifact_prefix }}. tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > rust-gh-example-${{ matrix.artifact_prefix }} .sha256
92+ certutil -hashfile $RELEASE_NAME. tar.gz sha256 | grep -E [A-Fa-f0-9]{64} > $RELEASE_NAME .sha256
5593 else
56- shasum -a 256 rust-gh-example-${{ matrix.artifact_prefix }}. tar.gz > rust-gh-example-${{ matrix.artifact_prefix }} .sha256
94+ shasum -a 256 $RELEASE_NAME. tar.gz > $RELEASE_NAME .sha256
5795 fi
5896 - name : Releasing assets
5997 uses : softprops/action-gh-release@v1
6098 with :
6199 files : |
62- target/${{ matrix.target }}/release/rust-gh-example-${{ matrix.artifact_prefix }} .tar.gz
63- target/${{ matrix.target }}/release/rust-gh-example-${{ matrix.artifact_prefix }} .sha256
100+ target/${{ matrix.job. target }}/release/rust-gh-example-* .tar.gz
101+ target/${{ matrix.job. target }}/release/rust-gh-example-* .sha256
64102 env :
65103 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
66104
0 commit comments