Open source CapCut alternative.
TypeScript
Simplify release workflow version bump
David Lece629fde5bcc
diff --git a/.github/workflows/promote-donkey-release.yml b/.github/workflows/promote-donkey-release.ymlindex e48d6c75..b16b0062 100644--- a/.github/workflows/promote-donkey-release.yml+++ b/.github/workflows/promote-donkey-release.yml@@ -3,30 +3,15 @@ name: Release Donkeyon:workflow_dispatch:inputs:- version:- description: Numeric version to build and release, for example 0.1.0.+ bump:+ description: Version component to bump from the latest numeric release. Starts at 0.1.0 when no release exists.required: true- type: string- build:- description: Optional CFBundleVersion build number. Defaults to the GitHub Actions run number.- required: false- default: ""- type: string- promote_major:- description: Move the vMAJOR alias tag to this version.- required: true- default: true- type: boolean- promote_minor:- description: Move the vMAJOR.MINOR alias tag to this version.- required: true- default: true- type: boolean- promote_latest:- description: Move the latest alias tag to this version.- required: true- default: true- type: boolean+ default: patch+ type: choice+ options:+ - patch+ - minor+ - majorpermissions:contents: write@@ -60,17 +45,41 @@ jobs:- name: Prepare release valuesid: releaserun: |- version="${{ inputs.version }}"- version="${version#v}"- if [[ ! "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then- echo "Version must be numeric SemVer, for example 0.1.0 or v0.1.0." >&2- exit 1- fi-- build="${{ inputs.build }}"- if [[ -z "$build" ]]; then- build="${GITHUB_RUN_NUMBER}"- fi+ version="$(python3 - "${{ inputs.bump }}" <<'PY'+ from __future__ import annotations++ import re+ import subprocess+ import sys++ bump = sys.argv[1]+ if bump not in {"major", "minor", "patch"}:+ raise SystemExit(f"Unsupported version bump: {bump}")++ tag_re = re.compile(r"^v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$")+ tags = subprocess.check_output(["git", "tag", "--list"], text=True).splitlines()+ versions = [+ tuple(int(part) for part in match.groups())+ for tag in tags+ if (match := tag_re.match(tag.strip()))+ ]++ if versions:+ major, minor, patch = max(versions)+ if bump == "major":+ major, minor, patch = major + 1, 0, 0+ elif bump == "minor":+ minor, patch = minor + 1, 0+ else:+ patch += 1+ else:+ major, minor, patch = 0, 1, 0++ print(f"{major}.{minor}.{patch}")+ PY+ )"++ build="${GITHUB_RUN_NUMBER}"if [[ ! "$build" =~ ^[0-9]+$ ]]; thenecho "Build must be numeric for CFBundleVersion." >&2exit 1@@ -160,14 +169,4 @@ jobs:--commit)- if [[ "${{ inputs.promote_major }}" != "true" ]]; then- args+=(--no-promote-major)- fi- if [[ "${{ inputs.promote_minor }}" != "true" ]]; then- args+=(--no-promote-minor)- fi- if [[ "${{ inputs.promote_latest }}" != "true" ]]; then- args+=(--no-promote-latest)- fi-python3 scripts/promote-github-release.py "${args[@]}"diff --git a/docs/guides/releasing-donkey.md b/docs/guides/releasing-donkey.mdindex a57f4721..34d64591 100644--- a/docs/guides/releasing-donkey.md+++ b/docs/guides/releasing-donkey.md@@ -4,8 +4,9 @@ Donkey production releases are distributed through GitHub Releases. TheSupabase Storage `/release` bucket is not part of the release path.The release entrypoint is the `Release Donkey` GitHub Actions workflow. A-maintainer chooses a new numeric version in the GitHub UI, and the workflow-builds the latest default-branch code into the release artifact.+maintainer chooses whether to bump the major, minor, or patch version in the+GitHub UI, and the workflow builds the latest default-branch code into the+release artifact.## Release Boundaries@@ -62,21 +63,21 @@ at packaging time and reject future updates signed by a different private key.1. Open GitHub Actions for the repository.2. Select `Release Donkey`.3. Click `Run workflow`.-4. Enter the new numeric version, such as `0.1.1`.-5. Leave `build` blank unless a specific `CFBundleVersion` is required.-6. Keep major, minor, and latest promotion enabled for normal releases.-7. Run the workflow.--The workflow checks out the latest default branch, validates the version, builds-the macOS app, packages `dist/Donkey.dmg`, signs the DMG with the Sparkle-private key, creates or updates the numeric GitHub Release, uploads the DMG and-checksum, updates `site/public/appcast.xml`, updates the website download-constant, commits those site/appcast changes, marks the numeric release as-GitHub's latest release, and moves the optional alias tags.+4. Choose `patch`, `minor`, or `major`.+5. Run the workflow.++The workflow checks out the latest default branch, fetches existing numeric+release tags, derives the next version from the selected bump, builds the macOS+app, packages `dist/Donkey.dmg`, signs the DMG with the Sparkle private key,+creates or updates the numeric GitHub Release, uploads the DMG and checksum,+updates `site/public/appcast.xml`, updates the website download constant,+commits those site/appcast changes, marks the numeric release as GitHub's latest+release, and moves the alias tags. When no numeric release tag exists yet, the+workflow starts at `0.1.0`.## Alias Tags-The workflow can move these alias tags to the released commit:+The workflow moves these alias tags to the released commit:- `vMAJOR`- `vMAJOR.MINOR`