-
Notifications
You must be signed in to change notification settings - Fork 0
221 lines (187 loc) · 6.21 KB
/
Copy pathrelease.yml
File metadata and controls
221 lines (187 loc) · 6.21 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
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
211
212
213
214
215
216
217
218
219
220
221
name: Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
tag:
description: "Existing tag to package, for example v0.1.0-alpha.1"
required: true
dry_run:
description: "Build and package without creating/updating a release"
required: false
default: "true"
permissions:
contents: read
env:
ZIG_VERSION: "0.16.0"
concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: false
jobs:
verify:
name: verify release candidate
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.version.outputs.tag }}
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve version
id: version
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
tag="${{ inputs.tag }}"
git fetch --tags --force
git checkout "${tag}"
else
tag="${GITHUB_REF_NAME}"
fi
if [[ ! "${tag}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([-+][0-9A-Za-z.-]+)?$ ]]; then
echo "release tag must look like v0.1.0 or v0.1.0-alpha.1" >&2
exit 1
fi
echo "tag=${tag}" >> "${GITHUB_OUTPUT}"
echo "version=${tag#v}" >> "${GITHUB_OUTPUT}"
- name: Set up Zig
uses: mlugg/setup-zig@v2.2.1
with:
version: ${{ env.ZIG_VERSION }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest
- name: Check whitespace
run: git show --check --format=short --no-renames HEAD
- name: Check Zig formatting
run: |
zig fmt --check build.zig build.zig.zon
find src -name '*.zig' -print0 | sort -z | xargs -0 zig fmt --check
- name: Run public-safety scan
run: python scripts/check_public_safety.py
- name: Check runtime boundary
run: python scripts/check_runtime_boundary.py
- name: Build Zig binary
run: zig build --summary all
- name: Run Zig tests
run: zig build test --summary all
- name: Build release-safe binary
run: zig build -Doptimize=ReleaseSafe --summary all
- name: Version consistency
run: |
test "$(./zig-out/bin/dxt version)" = "${{ steps.version.outputs.version }}"
grep -q ".version = \"${{ steps.version.outputs.version }}\"" build.zig.zon
package:
name: package ${{ matrix.target }}
runs-on: ubuntu-latest
needs: verify
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-linux-gnu
smoke: true
- target: aarch64-linux-gnu
smoke: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.verify.outputs.tag }}
- name: Set up Zig
uses: mlugg/setup-zig@v2.2.1
with:
version: ${{ env.ZIG_VERSION }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build target
run: zig build -Doptimize=ReleaseSafe -Dtarget=${{ matrix.target }} --summary all
- name: Smoke test native target
if: matrix.smoke
run: |
./zig-out/bin/dxt --help
test "$(./zig-out/bin/dxt version)" = "${{ needs.verify.outputs.version }}"
- name: Package
shell: bash
run: |
version="${{ needs.verify.outputs.version }}"
name="dxt-v${version}-${{ matrix.target }}"
mkdir -p "dist/${name}"
cp zig-out/bin/dxt "dist/${name}/dxt"
cp README.md CHANGELOG.md SECURITY.md "dist/${name}/"
cp -R docs "dist/${name}/docs"
test ! -f LICENSE || cp LICENSE "dist/${name}/"
tar -C dist -czf "dist/${name}.tar.gz" "${name}"
tar -tzf "dist/${name}.tar.gz"
- name: Check release archive safety
run: |
python scripts/check_release_archive.py \
"dist/dxt-v${{ needs.verify.outputs.version }}-${{ matrix.target }}.tar.gz" \
--version "${{ needs.verify.outputs.version }}" \
--target "${{ matrix.target }}"
- name: Upload packaged binary
uses: actions/upload-artifact@v4
with:
name: dxt-${{ needs.verify.outputs.tag }}-${{ matrix.target }}
path: dist/*.tar.gz
if-no-files-found: error
publish:
name: create draft release
runs-on: ubuntu-latest
needs:
- verify
- package
if: github.event_name == 'push' || inputs.dry_run != 'true'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.verify.outputs.tag }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate checksums
run: |
cd dist
sha256sum *.tar.gz > "dxt-${{ needs.verify.outputs.tag }}-SHA256SUMS.txt"
cat "dxt-${{ needs.verify.outputs.tag }}-SHA256SUMS.txt"
- name: Check release archives and checksums
run: |
python scripts/check_release_archive.py \
dist/*.tar.gz \
--version "${{ needs.verify.outputs.version }}" \
--checksum-file "dist/dxt-${{ needs.verify.outputs.tag }}-SHA256SUMS.txt"
- name: Create or update draft release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
tag="${{ needs.verify.outputs.tag }}"
if gh release view "${tag}" >/dev/null 2>&1; then
gh release upload "${tag}" dist/* --clobber
else
gh release create "${tag}" dist/* \
--draft \
--verify-tag \
--title "dxt ${tag}" \
--generate-notes
fi