-
Notifications
You must be signed in to change notification settings - Fork 9
233 lines (224 loc) · 8.47 KB
/
release.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: Test & Release
on:
push:
branches-ignore:
- 'pre_publish'
- 'publish'
tags-ignore:
- "quicssh-*"
pull_request:
env:
CRATE_NAME: quicssh-rs
GITHUB_TOKEN: ${{ github.token }}
RUST_BACKTRACE: 1
jobs:
build:
name: Compile for ${{ matrix.platform.name }} with Rust ${{ matrix.const.toolchain }}
runs-on: ${{ matrix.platform.host }}
permissions: write-all
strategy:
# assert perfect success
fail-fast: true
matrix:
const:
# contain constant information to use them as action style variables
# binbase: base file name (means the name without ext)
# as_r: true/false whether to act as release (but not release)
# is_r: true/false whether is release
# is_r: true/false whether is test
- binbase: quicssh-rs
toolchain: stable
as_r: ${{ startsWith(github.ref,'refs/tags/v') || startsWith(github.ref, 'refs/tags/test-release') }}
is_r: ${{ startsWith(github.ref,'refs/tags/v') }}
is_t: ${{ startsWith(github.ref, 'refs/tags/test-release') }}
platform:
# contain target platform information
# name: the conventional name of the platform
# host: runner
# target: rust target triple
# tarball: .tar.gz file name
# Platforms that don't work:
#
# - sparc64-unknown-linux-gnu - cannot compile openssl-sys
# - x86_64-unknown-illumos - weird error compiling openssl - "bin/sh: 1: granlib: not found"
- name: Windows-x86_64
host: windows-latest
target: x86_64-pc-windows-msvc
tarball: quicssh-Windows-x86_64.tar.gz
- name: FreeBSD-x86_64
host: ubuntu-20.04
target: x86_64-unknown-freebsd
tarball: quicssh-FreeBSD-x86_64.tar.gz
- name: Linux-i686
host: ubuntu-20.04
target: i686-unknown-linux-musl
tarball: quicssh-Linux-i686-musl.tar.gz
- name: Linux-x86_64
host: ubuntu-20.04
target: x86_64-unknown-linux-musl
tarball: quicssh-Linux-x86_64-musl.tar.gz
- name: Linux-arm
host: ubuntu-20.04
target: arm-unknown-linux-musleabi
tarball: quicssh-Linux-arm-musl.tar.gz
- name: Linux-armhf
host: ubuntu-20.04
target: armv7-unknown-linux-musleabihf
tarball: quicssh-Linux-armhf-musl.tar.gz
- name: Linux-aarch64
host: ubuntu-20.04
target: aarch64-unknown-linux-musl
tarball: quicssh-Linux-aarch64-musl.tar.gz
- name: macOS-x86_64
host: macOS-latest
target: x86_64-apple-darwin
tarball: quicssh-Darwin-x86_64.tar.gz
- name: macOS-aarch64
host: macOS-latest
target: aarch64-apple-darwin
tarball: quicssh-Darwin-aarch64.tar.gz
steps:
# checkout
- uses: actions/checkout@v4
# build raw
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
- name: Install musl-tools # This is needed only for Linux x86_64, since compiles for other arch runs on docker
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
if: contains(matrix.platform.target, 'musl')
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: "build"
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.const.toolchain }}
args: --locked --release
strip: true
# upload raw
- name: Upload raw binary
uses: actions/upload-artifact@v4
with:
name: raw+${{ matrix.platform.target }}
path: "target/${{matrix.platform.target}}/release/quicssh-rs*"
#if : matrix.const.as_r
# build deb
- name: Install cargo-binstall
uses: cargo-bins/[email protected]
if: matrix.const.as_r && contains(matrix.platform.target, 'linux')
- name: BInstall cargo-deb
run: cargo binstall --force -y cargo-deb
if: matrix.const.as_r && contains(matrix.platform.target, 'linux')
- name: Build deb package
run: cargo deb --no-build --no-strip --target ${{ matrix.platform.target }}
if: matrix.const.as_r && contains(matrix.platform.target, 'linux')
# upload deb
- name: Upload deb package
uses: actions/upload-artifact@v4
with:
name: deb+${{ matrix.platform.target }}
path: "target/${{matrix.platform.target}}/debian/*.deb"
if: matrix.const.as_r && contains(matrix.platform.target, 'linux')
# build tar
- name: Build GitHub tarball
# in future we would need bundle etc files
shell: bash
run: |
cd target/${{ matrix.platform.target }}/release
if [[ "${{ contains(matrix.platform.target, 'windows') }}" = "true" ]];then
binname=${{ matrix.const.binbase }}.exe
else
binname=${{ matrix.const.binbase }}
fi
if [[ "${{ matrix.platform.host }}" = "windows-latest" ]]; then
7z a ../../../${{ matrix.platform.tarball }} $binname
else
tar czvf ../../../${{ matrix.platform.tarball }} $binname
fi
cd -
if: matrix.const.as_r
- name: Generate SHA-256
# This step currently not used, but necessary for brew binary install
run: shasum -a 256 ${{ matrix.platform.tarball }}
if: matrix.const.as_r
# upload tar
- name: Upload GitHub tarball
uses: actions/upload-artifact@v4
with:
name: tar+${{matrix.platform.target}}
path: ${{ matrix.platform.tarball }}
if: matrix.const.is_t
# publish tar
- name: Publish GitHub tarball
uses: softprops/action-gh-release@v1
with:
draft: true
files: "quicssh-*"
if: matrix.const.is_r && matrix.const.toolchain == 'stable'
repository:
name: Publish repository release
permissions: write-all
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref,'refs/tags/v')||startsWith(github.ref, 'refs/tags/test-release')
steps:
# checkout
- name: Checkout to pre_publish/publish
uses: actions/checkout@v4
with:
ref: ${{ startsWith(github.ref,'refs/tags/v') && 'publish' || 'pre_publish' }}
fetch-depth: 0
# move
- name: Set gitconfig to bot
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Move(reset) pre_publish to pushed commit
run: git reset --hard ${{github.ref_name}}
# build deb repo
- name: Install reprepro and dpkg-sig
run: sudo apt-get -y install reprepro dpkg-sig
# - name: Import gpg
# uses: crazy-max/ghaction-import-gpg@v6
# with:
# gpg_private_key: ${{ secrets.DEB_GPG_SECRET_KEY }}
- name: Download deb package
uses: actions/download-artifact@v4
with:
pattern: deb+*
merge-multiple: true
path: ./
- name: Build deb repository # here we need to provide gpg public (long) id if want to dpkg-sig
# now mine is exposed but no problem about valne...ty
run: |
cd publish/deb
for deb in $(ls ../../ |grep -E '\.deb$');do
# dpkg-sig -k 3C288CF6F3917DC32ED8605655C5F6BAACEEA951 --sign builder "../../$deb"
reprepro includedeb stable "../../$deb"
done
reprepro export
rm -rf db
cd -
git add ./publish/deb/
git commit -m "ci: generate/update debian repository"
# publish
- name: Force push
run: git push -f
crate:
name: Publish crate.io release
permissions: write-all
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref,'refs/tags/v')||startsWith(github.ref, 'refs/tags/test-release')
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
- name: Publish crate.io release
uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
dry-run: ${{ startsWith(github.ref, 'refs/tags/test-release') }}