-
Notifications
You must be signed in to change notification settings - Fork 1
197 lines (165 loc) · 5.86 KB
/
release.yml
File metadata and controls
197 lines (165 loc) · 5.86 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
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: read
actions: read
jobs:
gate:
name: Release gate — verify CI passed on this commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Verify CI passed on this commit
env:
GH_TOKEN: ${{ github.token }}
run: |
SHA=$(git rev-parse HEAD)
echo "Checking CI status for commit $SHA..."
# Wait up to 5 minutes for the Tests workflow to complete (tag push may race with CI)
for i in $(seq 1 30); do
RUN_JSON=$(gh run list --commit "$SHA" --workflow "Tests" --json status,conclusion --limit 1)
RUN_STATUS=$(echo "$RUN_JSON" | jq -r '.[0].status // "none"')
RUN_CONCLUSION=$(echo "$RUN_JSON" | jq -r '.[0].conclusion // "none"')
echo " Attempt $i: status=$RUN_STATUS conclusion=$RUN_CONCLUSION"
if [ "$RUN_STATUS" = "completed" ]; then
if [ "$RUN_CONCLUSION" = "success" ]; then
echo "Tests workflow passed."
exit 0
else
echo "::error::Tests workflow failed ($RUN_CONCLUSION). Fix tests before releasing."
exit 1
fi
fi
# not found or still running — wait and retry
sleep 10
done
echo "::error::Tests workflow did not complete within 5 minutes. Push to main first and wait for green CI."
exit 1
- name: Verify tag matches package version
run: |
TAG="${GITHUB_REF#refs/tags/v}"
PKG_VERSION=$(python3 -c "exec(open('src/kuberoku/_version.py').read()); print(__version__)")
if [ "$TAG" != "$PKG_VERSION" ]; then
echo "::error::Tag v${TAG} does not match _version.py (${PKG_VERSION})"
exit 1
fi
# ── Publish to PyPI ──────────────────────────────────────────────
publish:
name: Publish to PyPI
needs: gate
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install build tools
run: python -m pip install --upgrade pip build
- name: Verify tag matches package version
run: |
TAG="${GITHUB_REF#refs/tags/v}"
PKG_VERSION=$(python -c "exec(open('src/kuberoku/_version.py').read()); print(__version__)")
if [ "$TAG" != "$PKG_VERSION" ]; then
echo "::error::Tag v${TAG} does not match _version.py (${PKG_VERSION})"
exit 1
fi
- name: Build sdist and wheel
run: python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# ── Native binaries (5 targets) ─────────────────────────────────
binaries:
name: Binary — ${{ matrix.os }}-${{ matrix.arch }}
needs: gate
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: linux
arch: amd64
runner: ubuntu-latest
asset: kuberoku-linux-amd64
- os: linux
arch: arm64
runner: ubuntu-24.04-arm
asset: kuberoku-linux-arm64
- os: darwin
arch: arm64
runner: macos-latest
asset: kuberoku-darwin-arm64
- os: darwin
arch: amd64
runner: macos-15-intel
asset: kuberoku-darwin-amd64
- os: windows
arch: amd64
runner: windows-latest
asset: kuberoku-windows-amd64.exe
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install pyinstaller
- name: Build binary
run: pyinstaller kuberoku.spec
- name: Rename binary (unix)
if: matrix.os != 'windows'
run: mv dist/kuberoku dist/${{ matrix.asset }}
- name: Rename binary (windows)
if: matrix.os == 'windows'
shell: bash
run: mv dist/kuberoku.exe dist/${{ matrix.asset }}
- name: Smoke test
if: matrix.os != 'windows'
run: ./dist/${{ matrix.asset }} --version
- name: Smoke test (windows)
if: matrix.os == 'windows'
shell: bash
run: ./dist/${{ matrix.asset }} --version
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset }}
path: dist/${{ matrix.asset }}
# ── GitHub Release ──────────────────────────────────────────────
release:
name: Create GitHub Release
needs: [publish, binaries]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: List artifacts
run: ls -lhR artifacts/
- name: Create release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
artifacts/kuberoku-linux-amd64
artifacts/kuberoku-linux-arm64
artifacts/kuberoku-darwin-amd64
artifacts/kuberoku-darwin-arm64
artifacts/kuberoku-windows-amd64.exe
scripts/install.sh
scripts/install.ps1