Skip to content

Release

Release #1156

Workflow file for this run

name: Release
on:
workflow_run:
workflows: ["Release candidate"]
types: [completed]
branches:
- main
permissions: {}
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
concurrency:
group: release-main
cancel-in-progress: false
jobs:
candidate:
if: >-
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'main'
runs-on: ubuntu-24.04
outputs:
ready: ${{ steps.owner.outputs.ready }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
ref: ${{ github.event.workflow_run.head_sha }}
- id: owner
shell: bash
run: |
VERSION="$(sed -nE 's/^version = "([^"]+)".*/\1/p' pyproject.toml | head -n 1)"
TARGET="$(git ls-remote origin "refs/tags/release-candidate/$VERSION" | awk '{print $1}')"
[[ "$TARGET" == "${{ github.event.workflow_run.head_sha }}" ]] && echo 'ready=true' >> "$GITHUB_OUTPUT" || echo 'ready=false' >> "$GITHUB_OUTPUT"
publish:
needs: candidate
if: needs.candidate.outputs.ready == 'true'
runs-on: ubuntu-24.04
environment: pypi
permissions:
actions: read
contents: write
id-token: write
outputs:
version: ${{ steps.release.outputs.version }}
cascade_ready: ${{ steps.cascade-state.outputs.ready }}
env:
RELEASE_SHA: ${{ github.event.workflow_run.head_sha }}
RELEASE_BRANCH: main
REQUIRED_TEST_RUN_ID: ${{ github.event.workflow_run.id }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
fetch-depth: 0
ref: ${{ env.RELEASE_SHA }}
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: '3.12'
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
with:
version: "0.10.6"
enable-cache: false
- name: Record verified release
id: release
run: |
set -Eeuo pipefail
VERSION="$(sed -nE 's/^version = "([^"]+)".*/\1/p' pyproject.toml | head -n 1)"
test -n "$VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Publish tested commit
env:
GH_TOKEN: ${{ secrets.RELEASE_GH_TOKEN || github.token }}
run: ./bin/release.sh
- name: Confirm this tested commit owns the release tag
id: cascade-state
run: |
set -Eeuo pipefail
TARGET=""
while read -r sha _; do
TARGET="$sha"
done < <(git ls-remote origin "refs/tags/v${{ steps.release.outputs.version }}")
if [[ "$TARGET" == "$RELEASE_SHA" ]]; then
echo "ready=true" >> "$GITHUB_OUTPUT"
else
echo "ready=false" >> "$GITHUB_OUTPUT"
fi
cascade:
name: Cascade verified release
needs: publish
if: needs.publish.outputs.cascade_ready == 'true'
permissions:
actions: read
contents: read
uses: ArchiveBox/monorepo/.github/workflows/cascade-release.yml@main
with:
upstream_package: abxpkg
upstream_version: ${{ needs.publish.outputs.version }}
upstream_artifact_name: abxpkg-dist-${{ github.event.workflow_run.head_sha }}
secrets:
release_token: ${{ secrets.RELEASE_GH_TOKEN }}