Skip to content

Commit 0efd400

Browse files
authored
ci(release): add a manual dry run that builds everything and publishes nothing (#14)
## Summary `release.yml` runs only for a `v*` tag, so the only way to test a release is to make one. This PR adds `workflow_dispatch`. A manual run is a dry run: `test`, `build`, `build-tui` and `build-tui-macos-arm` run and keep their artifacts. `publish-pypi` and `github-release` do not run. ```yaml on: push: tags: - "v*" workflow_dispatch: # publish-pypi and github-release: if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') ``` The `if` tests the event, not only the ref. A manual run can name a tag as its ref, and then `startsWith(github.ref, 'refs/tags/v')` alone is true. Seven lines change, in one file. Nothing else changes: the jobs, the artifacts and the tag trigger are the same. ## Why now This is exit condition 3 of the V0.5 milestone ([v0.5.0](https://github.com/zy1233/pi-python/milestone/1)). - The macOS arm64 job (PR #6) has never run in a release. `github-release` waits for it. `publish-pypi` does not wait: if the macOS job fails, the Python packages are already on PyPI and the GitHub Release is missing. - Linux CI cannot compile code that is only for macOS. 75 files under `tui/crates` hold `cfg(target_os = "macos")`. After the last macOS build, 88 files of `tui/` changed, and 8 of them hold such code. - The release workflow of v0.3.0 needed three runs before it passed. ## Verification - `actionlint` 1.7.12: no findings. - The YAML parses, and the two `if` lines are the only changed conditions. - The dry run ran from this branch (`gh workflow run release.yml --ref ci/release-dry-run`; GitHub accepts a manual run from a branch that is not on `main`). Run [38223353755](https://github.com/zy1233/pi-python/actions/runs/38223353755) succeeded in 27 minutes: `test` 97 s, the Python packages 29 s, the Linux x86_64 binary 16 m 26 s, the macOS arm64 binary 25 m 27 s. `publish-pypi` and `github-release` were skipped, so nothing was published. The artifacts (`dist`, `tui-binary`, `tui-binary-macos-arm64`) are kept until 2027-01-10. - Not verified: the true side of the two `if` lines. It runs only for a real tag push. ## For the reviewer - The three build jobs need `test`, so a dry run first runs the full pytest suite and Ruff. A dry run costs as much as a release run. The repository is public, so the minutes are free. - A dry run does not use the `pypi` environment: the job that needs it is skipped. - Creating the tag and the release stays a step for the maintainer.
1 parent d57fd9b commit 0efd400

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
tags:
66
- "v*"
7+
# A manual run is a dry run. It tests and builds everything and keeps the artifacts,
8+
# but it publishes nothing: publish-pypi and github-release run only for a tag push.
9+
workflow_dispatch:
710

811
permissions:
912
contents: write
@@ -145,6 +148,8 @@ jobs:
145148
publish-pypi:
146149
name: Publish to PyPI
147150
needs: build
151+
# Only a tag push publishes. Test the event too: a manual run can name a tag as its ref.
152+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
148153
runs-on: ubuntu-latest
149154
environment: pypi
150155
steps:
@@ -162,6 +167,8 @@ jobs:
162167
github-release:
163168
name: GitHub Release
164169
needs: [build, build-tui, build-tui-macos-arm]
170+
# Same rule as publish-pypi.
171+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
165172
runs-on: ubuntu-latest
166173
permissions:
167174
contents: write

0 commit comments

Comments
 (0)