-
-
Notifications
You must be signed in to change notification settings - Fork 64
197 lines (183 loc) · 6.22 KB
/
cd.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: CD
on:
push:
tags:
- "v*.*.*"
jobs:
publish-github:
name: Publish for ${{ matrix.build.OS }} (${{ matrix.build.TARGET }})
runs-on: ${{ matrix.build.OS }}
strategy:
fail-fast: false
matrix:
build:
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-linux-gnu,
ALL_FEATURES: true,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: x86_64-unknown-linux-musl,
ALL_FEATURES: true,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: aarch64-unknown-linux-gnu,
ALL_FEATURES: true,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: riscv64gc-unknown-linux-gnu,
ALL_FEATURES: true,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: i686-unknown-linux-gnu,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: i686-unknown-linux-musl,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: aarch64-unknown-linux-musl,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: armv5te-unknown-linux-gnueabi,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: armv7-unknown-linux-gnueabihf,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: arm-unknown-linux-gnueabi,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: arm-unknown-linux-gnueabihf,
ALL_FEATURES: false,
}
- {
OS: ubuntu-22.04,
TOOLCHAIN: stable,
TARGET: powerpc64le-unknown-linux-gnu,
ALL_FEATURES: false,
}
- {
OS: windows-2022,
TOOLCHAIN: stable,
TARGET: x86_64-pc-windows-msvc,
ALL_FEATURES: false,
}
- {
OS: macos-14,
TOOLCHAIN: stable,
TARGET: x86_64-apple-darwin,
ALL_FEATURES: false,
}
- {
OS: macos-14,
TOOLCHAIN: stable,
TARGET: aarch64-apple-darwin,
ALL_FEATURES: false,
}
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set the release version
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.build.TOOLCHAIN }}
targets: ${{ matrix.build.TARGET }}
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Build
shell: bash
run: |
if [ "${{ matrix.build.ALL_FEATURES }}" = true ]; then
cargo build --release --locked --target ${{ matrix.build.TARGET }}
else
cargo build --release --no-default-features --locked --target ${{ matrix.build.TARGET }}
fi
- name: Prepare release assets
shell: bash
run: |
mkdir -p release
cp {LICENSE-MIT,LICENSE-APACHE,README.md,CHANGELOG.md} release/
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
cp target/${{ matrix.build.TARGET }}/release/binsider.exe release/
else
cp target/${{ matrix.build.TARGET }}/release/binsider release/ && strip -s release/binsider
fi
mv release/ binsider-${{env.RELEASE_VERSION}}/
- name: Create release artifacts
shell: bash
run: |
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
7z a -tzip "binsider-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.zip" \
binsider-${{ env.RELEASE_VERSION }}/
else
tar -czvf binsider-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \
binsider-${{ env.RELEASE_VERSION }}/
shasum -a 512 binsider-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz \
> binsider-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz.sha512
fi
- name: Sign the release
if: matrix.build.OS != 'windows-2022'
run: |
echo "${{ secrets.GPG_RELEASE_KEY }}" | base64 --decode > private.key
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --import private.key
echo "${{secrets.GPG_PASSPHRASE}}" | gpg --pinentry-mode=loopback \
--passphrase-fd 0 --detach-sign \
binsider-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}.tar.gz
- name: Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
args: --latest --github-repo ${{ github.repository }}
env:
OUTPUT: CHANGES.md
- name: Upload the binary releases
uses: svenstaro/upload-release-action@v2
with:
file: binsider-${{ env.RELEASE_VERSION }}-${{ matrix.build.TARGET }}*
file_glob: true
overwrite: true
tag: ${{ github.ref }}
release_name: "Release v${{ env.RELEASE_VERSION }}"
body: ${{ steps.git-cliff.outputs.content }}
repo_token: ${{ secrets.RELEASE_TOKEN }}
publish-crates-io:
name: Publish on crates.io
needs: publish-github
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Publish
run: cargo publish --locked --token ${{ secrets.CARGO_REGISTRY_TOKEN }}