Skip to content

Commit eb1a939

Browse files
author
github-actions
committed
automatic update
from rust-github/template@37dda69
1 parent 6045baf commit eb1a939

File tree

1 file changed

+21
-36
lines changed

1 file changed

+21
-36
lines changed

.github/workflows/cd.yml

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,107 +8,92 @@ on:
88
jobs:
99

1010
publish:
11-
name: Publishing for ${{ matrix.job.os }}
11+
name: Publishing for ${{ matrix.job.os-name }}-${{ matrix.job.architecture }}
1212
runs-on: ${{ matrix.job.os }}
1313
permissions:
1414
contents: write
1515
strategy:
16+
fail-fast: false
1617
matrix:
1718
rust: [stable]
1819
job:
1920
- os: macos-latest
2021
os-name: macos
2122
target: x86_64-apple-darwin
2223
architecture: x86_64
23-
binary-postfix: ""
24-
use-cross: false
2524
- os: macos-latest
2625
os-name: macos
2726
target: aarch64-apple-darwin
2827
architecture: arm64
29-
binary-postfix: ""
30-
use-cross: false
3128
- os: ubuntu-latest
3229
os-name: linux
3330
target: x86_64-unknown-linux-gnu
3431
architecture: x86_64
35-
binary-postfix: ""
36-
use-cross: false
3732
- os: windows-latest
3833
os-name: windows
3934
target: x86_64-pc-windows-msvc
4035
architecture: x86_64
41-
binary-postfix: ".exe"
42-
use-cross: false
4336
- os: ubuntu-latest
4437
os-name: linux
4538
target: aarch64-unknown-linux-gnu
4639
architecture: arm64
47-
binary-postfix: ""
48-
use-cross: true
4940
- os: ubuntu-latest
5041
os-name: linux
5142
target: i686-unknown-linux-gnu
5243
architecture: i686
53-
binary-postfix: ""
54-
use-cross: true
5544

5645
steps:
5746
- name: Checkout repository
5847
uses: actions/checkout@v4
5948
- name: Install Rust toolchain
60-
uses: actions-rs/toolchain@v1
49+
uses: dtolnay/rust-toolchain@stable
6150
with:
6251
toolchain: ${{ matrix.rust }}
6352
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
6955
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 }}
7459

7560
- name: install strip command
61+
if: matrix.job.target == 'aarch64-unknown-linux-gnu'
7662
shell: bash
7763
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
8266
- name: Packaging final binary
8367
shell: bash
8468
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
8673
8774
####### reduce binary size by removing debug symbols #######
88-
BINARY_NAME=rust-gh-example${{ matrix.job.binary-postfix }}
8975
if [[ ${{ matrix.job.target }} == aarch64-unknown-linux-gnu ]]; then
9076
GCC_PREFIX="aarch64-linux-gnu-"
9177
else
9278
GCC_PREFIX=""
9379
fi
94-
"$GCC_PREFIX"strip $BINARY_NAME
80+
"$GCC_PREFIX"strip $BINARY
9581
9682
########## create tar.gz ##########
83+
mkdir assets
9784
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
9986
10087
########## create sha256 ##########
10188
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
10390
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
10592
fi
10693
- name: Releasing assets
10794
uses: softprops/action-gh-release@v2
10895
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/*
11297
env:
11398
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11499

0 commit comments

Comments
 (0)