-
Notifications
You must be signed in to change notification settings - Fork 33
176 lines (148 loc) · 6.84 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
name: Release Workflow
on:
release:
types: [created]
jobs:
build:
strategy:
fail-fast: false
matrix:
target:
- os: linux
arch: "amd64"
rust-target: "x86_64-unknown-linux-gnu"
runs-on: ubuntu-latest
- os: linux
arch: "amd64-musl"
rust-target: "x86_64-unknown-linux-musl"
runs-on: ubuntu-latest
- os: linux
arch: "arm64"
rust-target: "aarch64-unknown-linux-gnu"
runs-on: ubuntu-latest
- os: darwin
arch: "amd64"
rust-target: "x86_64-apple-darwin"
runs-on: macos-latest
- os: darwin
arch: "arm64"
rust-target: "aarch64-apple-darwin"
runs-on: macos-latest
- os: windows
arch: "amd64"
rust-target: "x86_64-pc-windows-msvc"
runs-on: windows-latest
- os: windows
arch: "arm64"
rust-target: "aarch64-pc-windows-msvc"
runs-on: windows-latest
runs-on: ${{ matrix.target.runs-on }}
name: Build and save artifact
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Install toolchain
run: rustup toolchain install stable --profile minimal --target ${{ matrix.target.rust-target }} --no-self-update
- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross
if: ${{ matrix.target.os != 'windows' && matrix.target.os != 'darwin' }}
- uses: Swatinem/rust-cache@v2
- name: Build using cross
run: cross build --release --target ${{ matrix.target.rust-target }}
if: ${{ matrix.target.os != 'windows' && matrix.target.os != 'darwin' }}
- name: Build using cargo
run: cargo build --release --target ${{ matrix.target.rust-target }}
if: matrix.target.os == 'windows' || matrix.target.os == 'darwin'
- name: Set .exe extension for Windows
id: set_extension
run: echo "extension=.exe" >> $GITHUB_OUTPUT
if: ${{ matrix.target.os == 'windows' }}
- name: Set executable filename
id: set_filename
run: echo "filename=sshs-${{ matrix.target.os }}-${{ matrix.target.arch }}${{ steps.set_extension.outputs.extension }}" >> $GITHUB_OUTPUT
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
asset_name: ${{ steps.set_filename.outputs.filename }}
file: target/${{ matrix.target.rust-target }}/release/sshs${{ steps.set_extension.outputs.extension }}
- name: Compute checksums
run: shasum --algorithm 256 "target/${{ matrix.target.rust-target }}/release/sshs${{ steps.set_extension.outputs.extension }}" > "target/${{ matrix.target.rust-target }}/release/sshs${{ steps.set_extension.outputs.extension }}.sha256"
if: ${{ matrix.target.os != 'windows' }}
- name: Compute checksums
run: (Get-FileHash -Algorithm SHA256 -Path "target/${{ matrix.target.rust-target }}/release/sshs${{ steps.set_extension.outputs.extension }}").Hash | Out-File -FilePath "target/${{ matrix.target.rust-target }}/release/sshs${{ steps.set_extension.outputs.extension }}.sha256"
if: ${{ matrix.target.os == 'windows' }}
shell: pwsh
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
asset_name: ${{ steps.set_filename.outputs.filename }}.sha256
file: target/${{ matrix.target.rust-target }}/release/sshs${{ steps.set_extension.outputs.extension }}.sha256
package:
strategy:
fail-fast: false
matrix:
target:
- arch: "amd64"
rust-target: "x86_64-unknown-linux-gnu"
- arch: "arm64"
rust-target: "aarch64-unknown-linux-gnu"
needs: build
runs-on: ubuntu-latest
name: Package and upload artifact
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Configure dpkg for arm64
if: ${{ matrix.target.arch == 'arm64' }}
run: |
sudo dpkg --add-architecture arm64
sudo apt-get update
sudo apt-get install -y g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
- name: Install toolchain
run: rustup toolchain install stable --profile minimal --target ${{ matrix.target.rust-target }} --no-self-update
- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Install cargo-deb
run: cargo install cargo-deb
- name: Configure cargo for arm64
if: ${{ matrix.target.arch == 'arm64' }}
run: |
mkdir -p ~/.cargo/
touch ~/.cargo/config
echo "[target.aarch64-unknown-linux-gnu]\nobjcopy = { path = \"aarch64-linux-gnu-objcopy\" }\nstrip = { path = \"aarch64-linux-gnu-strip\" }\n" > ~/.cargo/config
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
- uses: Swatinem/rust-cache@v2
- uses: robinraju/release-downloader@v1.11
with:
tag: ${{ github.ref_name }}
fileName: sshs-linux-${{ matrix.target.arch }}
out-file-path: target/${{ matrix.target.rust-target }}/release
- name: Rename binary
run: mv target/${{ matrix.target.rust-target }}/release/sshs-linux-${{ matrix.target.arch }} target/${{ matrix.target.rust-target }}/release/sshs
- name: Create Debian package
run: cargo deb --no-build --target ${{ matrix.target.rust-target }} --output "target/${{ matrix.target.rust-target }}/debian/sshs-${{ matrix.target.arch }}.deb"
- name: Set deb filename
id: set_filename
run: echo "filename=sshs-linux-${{ matrix.target.arch }}.deb" >> $GITHUB_OUTPUT
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
asset_name: ${{ steps.set_filename.outputs.filename }}
file: target/${{ matrix.target.rust-target }}/debian/sshs-${{ matrix.target.arch }}.deb
- name: Compute checksums
run: shasum --algorithm 256 "target/${{ matrix.target.rust-target }}/debian/sshs-${{ matrix.target.arch }}.deb" > "target/${{ matrix.target.rust-target }}/debian/sshs-${{ matrix.target.arch }}.deb.sha256"
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
asset_name: ${{ steps.set_filename.outputs.filename }}.sha256
file: target/${{ matrix.target.rust-target }}/debian/sshs-${{ matrix.target.arch }}.deb.sha256