Skip to content

Release Runtime/API packages #22

Release Runtime/API packages

Release Runtime/API packages #22

Workflow file for this run

name: Release Runtime/API packages
on:
workflow_run:
workflows:
- Registry checks
types:
- completed
permissions:
contents: write
packages: write
concurrency:
group: registry-release-main
cancel-in-progress: false
jobs:
release:
name: Publish exact current-main packages
if: >-
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'main'
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout verified source
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
- name: Reject a moved main branch
env:
EXPECTED_SHA: ${{ github.event.workflow_run.head_sha }}
run: |
current_main=$(git ls-remote origin refs/heads/main | cut -f1)
test "$current_main" = "$EXPECTED_SHA"
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version-file: .python-version
- name: Install uv
run: python -m pip install uv==0.12.3
- name: Install pnpm
uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
with:
version: 11.11.0
- name: Set up Node and GitHub Packages
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version-file: package.json
cache: pnpm
registry-url: https://npm.pkg.github.com
scope: '@inkcre'
- name: Install frozen dependencies and build packages
run: |
uv sync --frozen
pnpm install --frozen-lockfile
uv run python -m build
pnpm --filter @inkcre/extension-runtime build
pnpm --filter @inkcre/extension-runtime pack --pack-destination dist
- name: Verify one coherent package version
id: version
run: |
python_version=$(python -c 'import tomllib; print(tomllib.load(open("pyproject.toml", "rb"))["project"]["version"])')
web_version=$(node -p 'require("./packages/runtime-web/package.json").version')
test "$python_version" = "$web_version"
echo "version=$python_version" >> "$GITHUB_OUTPUT"
- name: Require a new version for changed package surfaces
id: release
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
tag="v$VERSION"
if git rev-parse --verify --quiet "refs/tags/$tag" >/dev/null; then
if ! git diff --quiet "$tag^{commit}" HEAD -- \
.python-version package.json pnpm-lock.yaml pnpm-workspace.yaml \
pyproject.toml uv.lock pylock.toml scripts src packages/runtime-web; then
echo "Package surfaces changed after $tag; bump the coherent package version." >&2
exit 1
fi
echo "publish=false" >> "$GITHUB_OUTPUT"
else
echo "publish=true" >> "$GITHUB_OUTPUT"
fi
- name: Publish Web Runtime/API to GitHub Packages
if: steps.release.outputs.publish == 'true'
run: pnpm --filter @inkcre/extension-runtime publish --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create immutable source and Python package release
if: steps.release.outputs.publish == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SOURCE_SHA: ${{ github.event.workflow_run.head_sha }}
VERSION: ${{ steps.version.outputs.version }}
run: >-
gh release create "v$VERSION"
dist/*.tar.gz dist/*.tgz dist/*.whl
--repo "$GITHUB_REPOSITORY"
--target "$SOURCE_SHA"
--title "v$VERSION"
--generate-notes