-
Notifications
You must be signed in to change notification settings - Fork 7
215 lines (194 loc) · 7.21 KB
/
Copy pathrelease.yml
File metadata and controls
215 lines (194 loc) · 7.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
name: Release
# Builds standalone binaries for Linux / macOS / Windows and publishes them
# as assets on the GitHub Release corresponding to the pushed tag.
#
# Trigger:
# - Push a git tag matching v* (e.g. v0.1.0) → builds all targets and
# creates/updates a Release named after the tag.
# - workflow_dispatch → manual run for debugging; requires a tag input
# that already exists on the repository.
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Existing tag to build and release (e.g. v0.1.0)'
required: true
permissions:
contents: write
env:
PYTHON_VERSION: '3.11'
DISABLE_BREAKING_CHANGES_WARNING: '1'
jobs:
# ---------------------------------------------------------------------
# Version sanity check: setuptools-scm must resolve the tag to the
# same PEP 440 version we expect from the tag name (v1.2.3 → 1.2.3).
# ---------------------------------------------------------------------
verify-version:
name: Verify version
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.resolve.outputs.tag }}
version: ${{ steps.resolve.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.ref }}
fetch-depth: 0 # setuptools-scm needs full history + tags
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Resolve tag and version
id: resolve
shell: bash
run: |
TAG="${{ github.event.inputs.tag || github.ref_name }}"
VERSION="${TAG#v}"
python -m pip install --upgrade pip
python -m pip install "setuptools-scm>=8"
SCM_VERSION=$(python -m setuptools_scm)
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if [ "$VERSION" != "$SCM_VERSION" ]; then
echo "::error::Tag version ($VERSION) does not match setuptools-scm resolution ($SCM_VERSION). Make sure the tag points at the commit you want to release."
exit 1
fi
echo "Building version $VERSION from tag $TAG"
# ---------------------------------------------------------------------
# Matrix build: 5 targets
# ---------------------------------------------------------------------
build:
name: Build ${{ matrix.target }}
needs: verify-version
runs-on: ${{ matrix.runner }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
include:
- target: linux-amd64
runner: ubuntu-latest
container: quay.io/pypa/manylinux_2_28_x86_64
ext: ''
archive: tar.gz
- target: linux-arm64
runner: ubuntu-24.04-arm
container: quay.io/pypa/manylinux_2_28_aarch64
ext: ''
archive: tar.gz
- target: darwin-amd64
runner: macos-13
container: ''
ext: ''
archive: tar.gz
- target: darwin-arm64
runner: macos-latest
container: ''
ext: ''
archive: tar.gz
- target: windows-amd64
runner: windows-latest
container: ''
ext: '.exe'
archive: zip
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.verify-version.outputs.tag }}
fetch-depth: 0 # setuptools-scm needs full history + tags
# manylinux images ship multiple Pythons under /opt/python; expose one.
- name: Configure Python (manylinux container)
if: matrix.container != ''
shell: bash
run: |
PY=/opt/python/cp311-cp311/bin
echo "$PY" >> "$GITHUB_PATH"
"$PY/python" -m pip install --upgrade pip
- name: Setup Python (host runner)
if: matrix.container == ''
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install project + PyInstaller
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install -e .
python -m pip install pyinstaller
- name: Build binary
shell: bash
run: |
pyinstaller --clean --noconfirm agentrun.spec
ls -lh dist/
- name: Smoke test binary
shell: bash
run: |
./dist/agentrun${{ matrix.ext }} --version
# --- Package (Unix) -----------------------------------------------
- name: Package tar.gz (Unix)
if: matrix.archive == 'tar.gz'
shell: bash
run: |
VERSION="${{ needs.verify-version.outputs.version }}"
ASSET="agentrun-${VERSION}-${{ matrix.target }}.tar.gz"
cd dist
tar czf "../${ASSET}" "agentrun${{ matrix.ext }}"
cd ..
shasum -a 256 "${ASSET}" > "${ASSET}.sha256"
echo "ASSET=${ASSET}" >> "$GITHUB_ENV"
# --- Package (Windows) --------------------------------------------
- name: Package zip (Windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
$version = "${{ needs.verify-version.outputs.version }}"
$asset = "agentrun-$version-${{ matrix.target }}.zip"
Compress-Archive -Path "dist/agentrun${{ matrix.ext }}" -DestinationPath $asset -Force
$hash = (Get-FileHash $asset -Algorithm SHA256).Hash.ToLower()
"$hash $asset" | Out-File -Encoding ascii "$asset.sha256"
echo "ASSET=$asset" >> $env:GITHUB_ENV
- uses: actions/upload-artifact@v4
with:
name: agentrun-${{ matrix.target }}
path: |
${{ env.ASSET }}
${{ env.ASSET }}.sha256
retention-days: 7
if-no-files-found: error
# ---------------------------------------------------------------------
# Collect all artifacts and publish the Release
# ---------------------------------------------------------------------
release:
name: Publish Release
needs: [verify-version, build]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List artifacts
run: ls -lh dist/
- name: Create combined checksums file
working-directory: dist
run: |
cat *.sha256 > SHA256SUMS
echo "---"
cat SHA256SUMS
- name: Publish to GitHub Releases
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.verify-version.outputs.tag }}
name: ${{ needs.verify-version.outputs.tag }}
draft: false
# PEP 440 pre-release markers: aN / bN / rcN / .devN. Tags must be in
# canonical form (no '-'), so we match on these substrings instead.
prerelease: ${{ contains(needs.verify-version.outputs.version, 'a') || contains(needs.verify-version.outputs.version, 'b') || contains(needs.verify-version.outputs.version, 'rc') || contains(needs.verify-version.outputs.version, 'dev') }}
generate_release_notes: true
files: |
dist/agentrun-*.tar.gz
dist/agentrun-*.zip
dist/agentrun-*.sha256
dist/SHA256SUMS