@@ -15,22 +15,16 @@ jobs:
15
15
runs-on : ubuntu-latest
16
16
steps :
17
17
- name : Checkout sources
18
- uses : actions/checkout@v2
18
+ uses : actions/checkout@v4
19
19
20
- - name : Install stable toolchain
21
- uses : actions-rs/toolchain@v1
22
- with :
23
- profile : minimal
24
- toolchain : stable
25
- override : true
20
+ - name : Install toolchain
21
+ uses : dtolnay/rust-toolchain@stable
26
22
27
23
- name : Run `cargo publish` - upload to crates.io
28
- uses : actions-rs/cargo@v1
29
24
env :
30
25
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_REGISTRY_TOKEN }}
31
26
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
32
- with :
33
- command : publish
27
+ run : cargo publish
34
28
35
29
upload :
36
30
name : ${{ matrix.job.os }} (${{ matrix.job.target }})
@@ -39,26 +33,28 @@ jobs:
39
33
fail-fast : false
40
34
matrix :
41
35
job :
42
- - { os: ubuntu-latest, target: x86_64-unknown-linux-musl, use-cross: true }
36
+ - { os: ubuntu-20.04, target: x86_64-unknown-linux-musl, use-cross: true }
37
+ - { os: ubuntu-latest, target: x86_64-unknown-linux-gnu, use-cross: true }
38
+ - { os: ubuntu-latest, target: aarch64-unknown-linux-musl, use-cross: true }
39
+ - { os: ubuntu-latest, target: i686-unknown-linux-musl, use-cross: true }
43
40
- { os: macos-latest, target: x86_64-apple-darwin, use-cross: true }
41
+ - { os: macos-latest, target: aarch64-apple-darwin, use-cross: true }
44
42
steps :
45
43
- name : Checkout source code
46
- uses : actions/checkout@v2
44
+ uses : actions/checkout@v4
47
45
48
46
- name : Extract crate information
49
47
shell : bash
50
48
run : |
51
- echo "PROJECT_NAME=${{ github.event.repository.name }} " >> $GITHUB_ENV
49
+ echo "PROJECT_NAME=psdm " >> $GITHUB_ENV
52
50
echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV
53
51
echo "PROJECT_MAINTAINER=$(sed -n 's/^authors = \["\(.*\)"\]/\1/p' Cargo.toml)" >> $GITHUB_ENV
54
52
echo "PROJECT_HOMEPAGE=$(sed -n 's/^homepage = "\(.*\)"/\1/p' Cargo.toml)" >> $GITHUB_ENV
55
- - name : Install Rust toolchain
56
- uses : actions-rs/toolchain@v1
53
+
54
+ - name : Install toolchain
55
+ uses : dtolnay/rust-toolchain@stable
57
56
with :
58
- toolchain : stable
59
- target : ${{ matrix.job.target }}
60
- override : true
61
- profile : minimal # minimal component installation (ie, no documentation)
57
+ targets : ${{ matrix.job.target }}
62
58
63
59
- name : Show version information (Rust, cargo, GCC)
64
60
shell : bash
@@ -69,48 +65,32 @@ jobs:
69
65
rustup default
70
66
cargo -V
71
67
rustc -V
72
- - name : Build
73
- uses : actions-rs/cargo@v1
68
+
69
+ - name : Install cross
70
+ uses : taiki-e/install-action@v2
74
71
with :
75
- use-cross : ${{ matrix.job.use-cross }}
76
- command : build
77
- args : --release --target=${{ matrix.job.target }}
72
+ tool : cross
78
73
79
- - name : Strip debug information from executable
80
- id : strip
74
+ - name : Build with cross
75
+ run : cross build --release --target=${{ matrix.job.target }}
76
+
77
+ - name : Set binary name & path
78
+ id : bin
81
79
shell : bash
82
80
run : |
83
81
# Figure out suffix of binary
84
82
EXE_suffix=""
85
- # Figure out what strip tool to use if any
86
- STRIP="strip"
83
+ case ${{ matrix.job.target }} in
84
+ *-pc-windows-*) EXE_suffix=".exe" ;;
85
+ esac;
86
+
87
87
# Setup paths
88
- BIN_DIR="${{ env.CICD_INTERMEDIATES_DIR }}/stripped-release-bin/"
89
- mkdir -p "${BIN_DIR}"
90
88
BIN_NAME="${{ env.PROJECT_NAME }}${EXE_suffix}"
91
- BIN_PATH="${BIN_DIR}/${BIN_NAME}"
92
- # Copy the release build binary to the result location
93
- cp "target/${{ matrix.job.target }}/release/${BIN_NAME}" "${BIN_DIR}"
94
- # Also strip if possible
95
- if [ -n "${STRIP}" ]; then
96
- "${STRIP}" "${BIN_PATH}"
97
- fi
98
- # Let subsequent steps know where to find the (stripped) bin
99
- echo ::set-output name=BIN_PATH::${BIN_PATH}
100
- echo ::set-output name=BIN_NAME::${BIN_NAME}
101
- - name : Set testing options
102
- id : test-options
103
- shell : bash
104
- run : |
105
- unset CARGO_TEST_OPTIONS
106
- unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--bin ${PROJECT_NAME}" ;; esac;
107
- echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
108
- - name : Run tests
109
- uses : actions-rs/cargo@v1
110
- with :
111
- use-cross : ${{ matrix.job.use-cross }}
112
- command : test
113
- args : --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}
89
+ BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}"
90
+
91
+ # Let subsequent steps know where to find the binary
92
+ echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT
93
+ echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT
114
94
115
95
- name : Create tarball
116
96
id : package
@@ -119,23 +99,28 @@ jobs:
119
99
PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac;
120
100
PKG_BASENAME=${PROJECT_NAME}-${PROJECT_VERSION}-${{ matrix.job.target }}
121
101
PKG_NAME=${PKG_BASENAME}${PKG_suffix}
122
- echo ::set-output name= PKG_NAME:: ${PKG_NAME}
102
+ echo " PKG_NAME= ${PKG_NAME}" >> $GITHUB_OUTPUT
123
103
PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package"
124
104
ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/"
125
105
mkdir -p "${ARCHIVE_DIR}"
106
+
126
107
# Binary
127
- cp "${{ steps.strip.outputs.BIN_PATH }}" "$ARCHIVE_DIR"
108
+ cp "${{ steps.bin.outputs.BIN_PATH }}" "$ARCHIVE_DIR"
109
+
128
110
# README, LICENSE and CHANGELOG files
129
111
cp "README.md" "LICENSE" "CHANGELOG.md" "$ARCHIVE_DIR"
112
+
130
113
# base compressed package
131
114
pushd "${PKG_STAGING}/" >/dev/null
132
115
case ${{ matrix.job.target }} in
133
116
*-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;;
134
117
*) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;;
135
118
esac;
136
119
popd >/dev/null
120
+
137
121
# Let subsequent steps know where to find the compressed package
138
- echo ::set-output name=PKG_PATH::"${PKG_STAGING}/${PKG_NAME}"
122
+ echo "PKG_PATH=${PKG_STAGING}/${PKG_NAME}" >> $GITHUB_OUTPUT
123
+
139
124
- name : " Artifact upload: tarball"
140
125
uses : actions/upload-artifact@master
141
126
with :
@@ -147,12 +132,14 @@ jobs:
147
132
shell : bash
148
133
run : |
149
134
unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/[0-9].* ]]; then IS_RELEASE='true' ; fi
150
- echo ::set-output name=IS_RELEASE::${IS_RELEASE}
135
+ echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT
136
+
151
137
- name : Publish archives and packages
152
- uses : softprops/action-gh-release@59c3b4891632ff9a897f99a91d7bc557467a3a22 # https://github.com/softprops/action-gh-release/issues/139
138
+ uses : softprops/action-gh-release@v2
153
139
if : steps.is-release.outputs.IS_RELEASE
154
140
with :
155
141
files : |
156
142
${{ steps.package.outputs.PKG_PATH }}
157
143
env :
158
144
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
145
+
0 commit comments