-
Notifications
You must be signed in to change notification settings - Fork 5
153 lines (125 loc) · 4.19 KB
/
release.yml
File metadata and controls
153 lines (125 loc) · 4.19 KB
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
name: Release
on:
push:
tags:
- "v*"
env:
CARGO_TERM_COLOR: always
ZIG_VERSION: "0.14.1"
ZIG_SHA256: "24aeeec8af16c381934a6cd7d95c807a8cb2cf7df9fa40d359aa884195c4716c"
permissions:
contents: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: cargo test --locked --verbose
build:
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
binary: sdme-x86_64-linux
- target: aarch64-unknown-linux-musl
binary: sdme-aarch64-linux
steps:
- uses: actions/checkout@v4
- name: Install Zig
run: |
curl -sL -o zig.tar.xz "https://ziglang.org/download/${ZIG_VERSION}/zig-x86_64-linux-${ZIG_VERSION}.tar.xz"
echo "${ZIG_SHA256} zig.tar.xz" | sha256sum -c -
mkdir -p "$HOME/.zig"
tar -xJf zig.tar.xz -C "$HOME/.zig" --strip-components=1
echo "$HOME/.zig" >> "$GITHUB_PATH"
rm zig.tar.xz
- name: Install cargo-zigbuild
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/rust-cross/cargo-zigbuild/releases/download/v0.22.1/cargo-zigbuild-installer.sh | sh
- name: Add rustup target
run: rustup target add ${{ matrix.target }}
- name: Build
run: cargo zigbuild --locked --release --target ${{ matrix.target }}
- name: Rename binary
run: cp target/${{ matrix.target }}/release/sdme ${{ matrix.binary }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.binary }}
path: ${{ matrix.binary }}
- name: Upload target binaries
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.target }}
path: |
target/${{ matrix.target }}/release/sdme
package:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
- target: aarch64-unknown-linux-musl
steps:
- uses: actions/checkout@v4
- name: Install packaging tools
run: cargo install cargo-deb cargo-generate-rpm
- name: Download target binary
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.target }}
path: target/${{ matrix.target }}/release
- name: Download x86_64 binary for completions
uses: actions/download-artifact@v4
with:
name: target-x86_64-unknown-linux-musl
path: /tmp/sdme-bin
- name: Generate completions
run: |
chmod +x /tmp/sdme-bin/sdme
mkdir -p dist/completions
/tmp/sdme-bin/sdme completions bash > dist/completions/sdme.bash
/tmp/sdme-bin/sdme completions zsh > dist/completions/_sdme
/tmp/sdme-bin/sdme completions fish > dist/completions/sdme.fish
- name: Ensure binaries are executable
run: chmod +x target/${{ matrix.target }}/release/sdme
- name: Build deb
run: cargo deb --no-build --no-strip --target ${{ matrix.target }}
- name: Build rpm
run: cargo generate-rpm --target ${{ matrix.target }}
- name: Collect packages
run: |
mkdir -p packages
cp target/debian/*.deb packages/
cp target/${{ matrix.target }}/generate-rpm/*.rpm packages/
ls -lh packages/
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: packages-${{ matrix.target }}
path: packages/*
release:
needs: [build, package]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate checksums
run: |
cd artifacts
sha256sum */sdme-*-linux */*.deb */*.rpm > SHA256SUMS
cat SHA256SUMS
- name: Create release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
artifacts/*/sdme-*-linux
artifacts/*/*.deb
artifacts/*/*.rpm
artifacts/SHA256SUMS