-
Notifications
You must be signed in to change notification settings - Fork 5
137 lines (120 loc) · 3.7 KB
/
Copy pathrelease.yml
File metadata and controls
137 lines (120 loc) · 3.7 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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: read
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: macos-15-intel
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl toolchain (linux-musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
set -euo pipefail
VERSION="${GITHUB_REF_NAME#v}"
TARGET="${{ matrix.target }}"
BIN="xfetch"
[ "$RUNNER_OS" = "Windows" ] && BIN="xfetch.exe"
mkdir -p stage
cp "target/${TARGET}/release/${BIN}" "stage/${BIN}"
cp LICENSE README.md stage/
if [ "$RUNNER_OS" = "Windows" ]; then
# GNU tar in Git Bash cannot write ZIP archives: `tar -a` with a
# .zip name silently produces a plain tar. Use the 7-Zip shipped
# on the runner instead.
(cd stage && 7z a -tzip "../xfetch-${VERSION}-${TARGET}.zip" . > /dev/null)
else
tar -czf "xfetch-${VERSION}-${TARGET}.tar.gz" -C stage .
fi
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.target }}
path: xfetch-*
if-no-files-found: error
checksums:
name: Generate SHA256SUMS
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: assets
pattern: '*'
merge-multiple: true
- name: Validate archives
run: |
set -euo pipefail
cd assets
for f in *.tar.gz; do
[ -e "$f" ] || continue
tar -tzf "$f" > /dev/null
listing="$(tar -tzf "$f")"
grep -Eq '(^|/)xfetch$' <<< "$listing" || { echo "$f does not contain xfetch"; exit 1; }
done
for f in *.zip; do
[ -e "$f" ] || continue
unzip -t "$f" > /dev/null
listing="$(unzip -Z1 "$f")"
grep -Eq '(^|/)xfetch\.exe$' <<< "$listing" || { echo "$f does not contain xfetch.exe"; exit 1; }
done
- name: Generate checksums
run: |
cd assets
sha256sum * > SHA256SUMS
cat SHA256SUMS
- name: Upload checksums
uses: actions/upload-artifact@v7
with:
name: checksums
path: assets/SHA256SUMS
release:
name: Publish release
needs: checksums
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: release-assets
pattern: '*'
merge-multiple: true
- name: Publish GitHub release
uses: softprops/action-gh-release@v3
with:
generate_release_notes: true
fail_on_unmatched_files: true
files: release-assets/*