-
Notifications
You must be signed in to change notification settings - Fork 0
218 lines (187 loc) · 6.01 KB
/
Copy pathrelease.yml
File metadata and controls
218 lines (187 loc) · 6.01 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Existing git tag to release (for example v2026.04.14)"
required: true
type: string
concurrency:
group: release-${{ github.event.inputs.tag || github.ref_name }}
cancel-in-progress: false
permissions:
contents: write
jobs:
validate:
name: Validate release tag
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.meta.outputs.tag }}
version: ${{ steps.meta.outputs.version }}
steps:
- name: Check out repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Resolve release metadata
id: meta
shell: bash
run: |
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
TAG="${{ github.event.inputs.tag }}"
if ! git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
echo "Tag ${TAG} does not exist on origin"
exit 1
fi
else
TAG="${GITHUB_REF_NAME}"
fi
if [[ ! "${TAG}" =~ ^v[0-9]{4}\.[0-9]{2}\.[0-9]{2}(\.[0-9]+)?$ ]]; then
echo "Tag ${TAG} does not match vYYYY.MM.DD or vYYYY.MM.DD.N"
exit 1
fi
VERSION="$(python - <<'PY'
from pathlib import Path
import re
text = Path("src/octopal/_version.py").read_text(encoding="utf-8")
match = re.search(r'__version__\s*=\s*"([^"]+)"', text)
if not match:
raise SystemExit("Could not find __version__ in src/octopal/_version.py")
print(match.group(1))
PY
)"
EXPECTED_VERSION="${TAG#v}"
if [[ "${VERSION}" != "${EXPECTED_VERSION}" ]]; then
echo "Version mismatch: tag=${EXPECTED_VERSION}, file=${VERSION}"
exit 1
fi
echo "tag=${TAG}" >> "${GITHUB_OUTPUT}"
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
test:
name: Run release checks
runs-on: ubuntu-latest
needs: validate
steps:
- name: Check out repository
uses: actions/checkout@v5
with:
ref: ${{ needs.validate.outputs.tag }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Set up uv
uses: astral-sh/setup-uv@v7
- name: Sync dependencies
run: uv sync --extra dev
- name: Run test suite
run: uv run pytest
desktop:
name: Build desktop app (${{ matrix.name }})
runs-on: ${{ matrix.os }}
needs: validate
strategy:
fail-fast: false
matrix:
include:
- name: Windows
os: windows-latest
command: npm run dist:win -- --publish never
artifact: octopal-desktop-windows
path: |
desktop/dist/*.exe
desktop/dist/*.exe.blockmap
desktop/dist/latest.yml
- name: macOS Intel + Apple Silicon
os: macos-15-intel
command: npm run dist:mac -- --publish never
artifact: octopal-desktop-macos
path: |
desktop/dist/*.dmg
desktop/dist/*.dmg.blockmap
desktop/dist/*.zip
desktop/dist/*.zip.blockmap
desktop/dist/latest-mac.yml
- name: Linux
os: ubuntu-latest
command: npm run dist:linux -- --publish never
artifact: octopal-desktop-linux
path: |
desktop/dist/*.AppImage
desktop/dist/*.AppImage.blockmap
desktop/dist/latest-linux.yml
steps:
- name: Check out repository
uses: actions/checkout@v5
with:
ref: ${{ needs.validate.outputs.tag }}
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
cache: npm
cache-dependency-path: desktop/package-lock.json
- name: Install desktop dependencies
working-directory: desktop
run: npm ci
- name: Set desktop release version
working-directory: desktop
env:
OCTOPAL_VERSION: ${{ needs.validate.outputs.version }}
shell: bash
run: |
DESKTOP_VERSION="$(node -e "console.log(process.env.OCTOPAL_VERSION.split('.').map((part) => String(Number(part))).join('.'))")"
npm pkg set "version=${DESKTOP_VERSION}"
- name: Build desktop installer
working-directory: desktop
run: ${{ matrix.command }}
- name: Upload desktop artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.path }}
if-no-files-found: error
publish:
name: Publish GitHub release
runs-on: ubuntu-latest
needs:
- validate
- test
- desktop
steps:
- name: Check out repository
uses: actions/checkout@v5
with:
ref: ${{ needs.validate.outputs.tag }}
- name: Download desktop artifacts
uses: actions/download-artifact@v4
with:
pattern: octopal-desktop-*
merge-multiple: true
path: release-assets
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ needs.validate.outputs.tag }}
VERSION: ${{ needs.validate.outputs.version }}
shell: bash
run: |
shopt -s nullglob
ASSETS=(release-assets/*)
if [[ "${#ASSETS[@]}" -eq 0 ]]; then
echo "No desktop release assets were downloaded"
exit 1
fi
if gh release view "${TAG}" >/dev/null 2>&1; then
echo "Release ${TAG} already exists; uploading desktop assets."
gh release upload "${TAG}" "${ASSETS[@]}" --clobber
exit 0
fi
gh release create "${TAG}" \
"${ASSETS[@]}" \
--verify-tag \
--title "Octopal ${VERSION}" \
--generate-notes