-
Notifications
You must be signed in to change notification settings - Fork 10
210 lines (179 loc) · 5.92 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
permissions:
contents: write
name: Build Rust project on multiple platforms when a new release is created
on:
release:
types: [created]
jobs:
build-windows:
runs-on: windows-latest
env:
FILE_NAME: nethsm-pkcs11-v${{ github.event.release.tag_name }}-x86_64-windows.dll
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable-x86_64-pc-windows-msvc
- uses: Swatinem/rust-cache@v2
- name: Build project
run: cargo build --release
- name: rename file
run: mv target/release/nethsm_pkcs11.dll ${{ env.FILE_NAME }}
- name: Upload to the release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.FILE_NAME }}
build-macos:
runs-on: macos-latest
env:
FILE_NAME: nethsm-pkcs11-v${{ github.event.release.tag_name }}-x86_64-macos.dylib
FILE_NAME_ARM: nethsm-pkcs11-v${{ github.event.release.tag_name }}-aarch64-macos.dylib
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable-x86_64-apple-darwin
target: aarch64-apple-darwin
- uses: Swatinem/rust-cache@v2
- name: Build project for MacOs aaarch64
run: cargo build --release --target aarch64-apple-darwin
- name: Build project
run: cargo build --release
- name: rename file
run: mv target/release/libnethsm_pkcs11.dylib ${{ env.FILE_NAME }}
- name: rename file arm
run: mv target/aarch64-apple-darwin/release/libnethsm_pkcs11.dylib ${{ env.FILE_NAME_ARM }}
- name: Upload to the release
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.FILE_NAME }}
${{ env.FILE_NAME_ARM }}
build-linux:
runs-on: ubuntu-latest
container:
image: ${{ matrix.os }}
strategy:
matrix:
os: ["alpine:3.18", "debian:12", "fedora:39", "fedora:40", "ubuntu:22.04", "ubuntu:24.04"]
rust-version: [stable]
env:
FILE_NAME: nethsm-pkcs11-v${{ github.event.release.tag_name }}-x86_64-${{ matrix.os }}.so
HOME: /root
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: install dependencies
run: |
case ${{matrix.os}} in
ubuntu* | debian* )
apt-get update
apt-get install -y curl gcc
;;
alpine*)
apk add curl musl-dev gcc
echo RUSTFLAGS="-C target-feature=-crt-static" >> $GITHUB_ENV
;;
fedora*)
dnf install -y curl gcc
;;
esac
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust-version }}
- uses: Swatinem/rust-cache@v2
- name: Build project
run: cargo build --release
- name: rename file
run: mv target/release/libnethsm_pkcs11.so ${{ env.FILE_NAME }}
- name: Upload to the release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.FILE_NAME }}
cross-build-linux:
runs-on: ubuntu-latest
name: Build on ${{ matrix.distro }} ${{ matrix.arch }}
strategy:
matrix:
include:
- arch: aarch64
distro: bullseye
target: aarch64-unknown-linux-gnu
- arch: aarch64
distro: ubuntu22.04
target: aarch64-unknown-linux-gnu
- arch: aarch64
distro: alpine_latest
target: aarch64-unknown-linux-musl
# Not supported by ring
# - arch: riscv64
# distro: ubuntu22.04
# target: riscv64gc-unknown-linux-gnu
env:
FILE_NAME: nethsm-pkcs11-v${{ github.event.release.tag_name }}-${{ matrix.arch }}-${{ matrix.distro }}.so
steps:
- uses: actions/checkout@v3
- uses: uraimo/run-on-arch-action@v2
name: Build artifact
id: build
with:
githubToken: ${{ github.token }}
arch: ${{ matrix.arch }}
distro: ${{ matrix.distro }}
setup: |
mkdir -p "${PWD}/artifacts"
dockerRunArgs: |
--volume "${PWD}/artifacts:/artifacts"
env: |
FILE_NAME: "${{env.FILE_NAME}}"
TARGET: "${{ matrix.target }}"
RUSTFLAGS: "-C target-feature=-crt-static"
shell: /bin/sh
install: |
case ${{matrix.distro}} in
ubuntu* | bullseye )
apt-get update
apt-get install -y curl gcc
;;
alpine*)
apk add curl musl-dev gcc
;;
esac
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. $HOME/.cargo/env
rustup target add ${{ matrix.target }}
run: |
. $HOME/.cargo/env
cargo build --release --target ${{ matrix.target }}
mv target/${{ matrix.target }}/release/libnethsm_pkcs11.so /artifacts/${{env.FILE_NAME}}
- uses: softprops/action-gh-release@v1
with:
files: artifacts/${{ env.FILE_NAME }}
upload-licenses:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: install cargo-license
run: cargo install cargo-license
- name: Generate licenses
run: ./tools/collect_licenses.sh
- name: rename file
run: mv _LICENSE LICENSE
- name: Upload to the release
uses: softprops/action-gh-release@v1
with:
files: LICENSE