-
Notifications
You must be signed in to change notification settings - Fork 1
176 lines (150 loc) · 4.63 KB
/
release.yml
File metadata and controls
176 lines (150 loc) · 4.63 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# .github/workflows/release.yml
name: Release (Linux tarball + Windows zip)
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
- uses: Swatinem/rust-cache@v2
- name: Install musl tools
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Build tarball
run: make tarball
- name: Upload artifact (Linux)
uses: actions/upload-artifact@v4
with:
name: linux-dist
path: |
dist/*.tar.gz
dist/*.buildinfo
dist/*.sha256
if-no-files-found: error
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Download WinDivert-2.2.2 and unzip
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://reqrypt.org/download/WinDivert-2.2.2-A.zip" -OutFile WinDivert.zip
Expand-Archive -Path WinDivert.zip -DestinationPath .\
Remove-Item .\WinDivert.zip
- name: Run PowerShell build
shell: pwsh
run: ./build.ps1 zipball
- name: Upload artifact (Windows)
uses: actions/upload-artifact@v4
with:
name: windows-dist
path: |
dist/*.zip
dist/*.buildinfo
dist/*.sha256
if-no-files-found: error
publish-crates-io:
name: Publish to crates.io (Trusted Publishing)
runs-on: ubuntu-latest
needs: [build-linux, build-windows]
environment: release
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Verify tag matches crate version
shell: bash
run: |
tag="${GITHUB_REF_NAME#v}"
crate_ver="$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version')"
[ "$tag" = "$crate_ver" ] || {
echo "Tag version ($tag) != Cargo.toml version ($crate_ver)" >&2
exit 1
}
echo "OK: tag $tag matches crate $crate_ver"
- name: Authenticate to crates.io (Trusted Publishing)
id: auth
uses: rust-lang/crates-io-auth-action@v1
- name: Publish
run: cargo publish --locked --no-verify || true
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
release:
runs-on: ubuntu-latest
needs: [build-linux, build-windows]
steps:
- uses: actions/checkout@v4
- name: Download Linux artifacts
uses: actions/download-artifact@v4
with:
name: linux-dist
path: upload
- name: Download Windows artifacts
uses: actions/download-artifact@v4
with:
name: windows-dist
path: upload
- name: Merge checksums
run: cat upload/*.sha256 > sha256sum.txt
- name: Format release note
run: |
cp RELEASE_NOTE.md auto_notes.md
- name: Format download link
run: |
{
echo "## Downloads"
for f in upload/*.{tar.gz,zip}; do
[ -e "$f" ] || continue
base=$(basename "$f")
echo "- [$base](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/$base)"
done
echo
} >> auto_notes.md
- name: Format and append buildinfo
run: |
{
echo "<details>"
echo "<summary>Build Info</summary>"
echo
shopt -s nullglob
files=(upload/*.buildinfo)
for f in "${files[@]}"; do
echo ""
echo "### $(basename "$f")"
while IFS=: read -r key value; do
key=$(echo "$key" | xargs)
value=$(echo "$value" | xargs)
echo "- **$key**: $value"
done < "$f"
done
echo "</details>"
} >> auto_notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: auto_notes.md
prerelease: ${{ contains(github.ref_name, '-') }}
files: |
upload/*.tar.gz
upload/*.zip
sha256sum.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}