-
Notifications
You must be signed in to change notification settings - Fork 0
Add GitHub release pipeline #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jmcte
wants to merge
1
commit into
main
Choose a base branch
from
codex/issue-86-release-pipeline
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+166
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*.*.*' | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| jobs: | ||
| github-release: | ||
| name: Build GitHub Release | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Install build backend | ||
| run: python -m pip install --upgrade pip build | ||
|
|
||
| - name: Validate tag and build artifacts | ||
| env: | ||
| RELEASE_TAG: ${{ github.ref_name }} | ||
| run: bash scripts/release/dry-run.sh | ||
|
|
||
| - name: Extract changelog body | ||
| env: | ||
| RELEASE_TAG: ${{ github.ref_name }} | ||
| run: | | ||
| python - <<'PY' > release-notes.md | ||
| from pathlib import Path | ||
| import os | ||
| import re | ||
| import sys | ||
|
|
||
| tag = os.environ["RELEASE_TAG"] | ||
| version = tag.removeprefix("v") | ||
| changelog = Path("CHANGELOG.md") | ||
| if not changelog.exists(): | ||
| raise SystemExit("CHANGELOG.md is required for release notes") | ||
|
|
||
| text = changelog.read_text() | ||
| pattern = rf"^## \[{re.escape(version)}\][^\n]*\n(?P<body>.*?)(?=^## \[|\Z)" | ||
| match = re.search(pattern, text, flags=re.MULTILINE | re.DOTALL) | ||
| if not match: | ||
| raise SystemExit(f"CHANGELOG.md has no section for {version}") | ||
|
|
||
| body = match.group("body").strip() | ||
| if not body: | ||
| raise SystemExit(f"CHANGELOG.md section for {version} is empty") | ||
| sys.stdout.write(body + "\n") | ||
| PY | ||
|
|
||
| - name: Create GitHub Release | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| RELEASE_TAG: ${{ github.ref_name }} | ||
| run: | | ||
| gh release create "$RELEASE_TAG" \ | ||
| --title "$RELEASE_TAG" \ | ||
| --notes-file release-notes.md \ | ||
| dist/*.tar.gz dist/*.whl dist/SHA256SUMS | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| RUN_FAST_CHECKS=1 | ||
| for arg in "$@"; do | ||
| case "$arg" in | ||
| --skip-fast-checks) | ||
| RUN_FAST_CHECKS=0 | ||
| ;; | ||
| *) | ||
| echo "usage: $0 [--skip-fast-checks]" >&2 | ||
| exit 2 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ -z "${PYTHON_BIN:-}" ]]; then | ||
| if command -v python3.12 >/dev/null 2>&1; then | ||
| PYTHON_BIN=python3.12 | ||
| else | ||
| PYTHON_BIN=python3 | ||
| fi | ||
| fi | ||
|
|
||
| PACKAGE_VERSION="$("$PYTHON_BIN" - <<'PY' | ||
| from pathlib import Path | ||
| import tomllib | ||
|
|
||
| project = tomllib.loads(Path("pyproject.toml").read_text())["project"] | ||
| print(project["version"]) | ||
| PY | ||
| )" | ||
| RELEASE_TAG="${RELEASE_TAG:-v$PACKAGE_VERSION}" | ||
|
|
||
| if [[ "$RELEASE_TAG" != "v$PACKAGE_VERSION" ]]; then | ||
| echo "release tag $RELEASE_TAG does not match pyproject.toml version $PACKAGE_VERSION" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$RUN_FAST_CHECKS" == "1" ]]; then | ||
| bash scripts/ci/run-fast-checks.sh | ||
| fi | ||
|
|
||
| "$PYTHON_BIN" - <<'PY' | ||
| import importlib.util | ||
| import sys | ||
|
|
||
| if importlib.util.find_spec("build") is None: | ||
| raise SystemExit("python -m build is unavailable; install it with: python -m pip install build") | ||
| PY | ||
|
|
||
| rm -rf dist | ||
| "$PYTHON_BIN" -m build | ||
|
|
||
| ( | ||
| cd dist | ||
| find . -maxdepth 1 -type f ! -name SHA256SUMS -print0 | sort -z | xargs -0 shasum -a 256 > SHA256SUMS | ||
| ) | ||
|
|
||
| echo "Built release artifacts for $RELEASE_TAG:" | ||
| ls -1 dist |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow unconditionally exits when
CHANGELOG.mdis absent, but the repository currently has noCHANGELOG.md, so every tag push that triggersrelease.ymlwill fail before creating a GitHub Release. Because this commit also enablescapabilities.release, the new release path is effectively unusable until a changelog file is added or a fallback note strategy is implemented.Useful? React with 👍 / 👎.