Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/canary-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Canary Release
on:
push:
# don't run on tags, run on commits
# https://github.com/orgs/community/discussions/25615
tags-ignore:
- "**"
branches:
- develop
workflow_dispatch:

permissions:
contents: read
packages: write

concurrency:
group: canary-${{ github.ref }}
cancel-in-progress: true

jobs:
compute_canary_version:
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.canary_version.outputs.version }}
steps:
- name: Compute canary version
id: canary_version
run: |
SHORT_SHA=${GITHUB_SHA::7}
DATE=$(date -u +%Y%m%dT%H%M%SZ)
echo "version=canary-${DATE}-${SHORT_SHA}" >> "$GITHUB_OUTPUT"

release_container:
needs: compute_canary_version
uses: ./.github/workflows/release-container.yml
with:
version: ${{ needs.compute_canary_version.outputs.version }}
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- "**"
branches:
- main
- develop
pull_request:
workflow_dispatch:

Expand Down
42 changes: 24 additions & 18 deletions .github/workflows/prep-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ on:
custom_version:
type: string
required: false
description: "Custom version (ignore for other bump types)"
generate_pre_release:
type: boolean
default: true
required: true
description: "Generate a RC build"
description: "Custom version (ignored for other bump types)"

permissions:
contents: write
Expand Down Expand Up @@ -75,11 +70,14 @@ jobs:
env:
CURR: ${{ steps.meta.outputs.current_version }}
CUSTOM: ${{ inputs.custom_version }}
BUMP: ${{ inputs.bump }}
BUMP: ${{ inputs.version_bump }}
run: |
set -euo pipefail

if [[ -n "${CUSTOM:-}" ]]; then then
if [[ -n "${CUSTOM:-}" ]]; then
echo "new_version=$CUSTOM" >> "$GITHUB_OUTPUT"
echo "Custom Bumped: $CURR -> $CUSTOM"
else
# strip any pre-release / build metadata for arithmetic (e.g., -rc.1, +build.5)
BASE="${CURR%%[-+]*}"

Expand All @@ -95,9 +93,6 @@ jobs:
NEW_VERSION="$MA.$MI.$PA"
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "Bumped: $CURR -> $NEW_VERSION"
else
echo "new_version=$CUSTOM" >> "$GITHUB_OUTPUT"
echo "Bumped: $CURR -> $CUSTOM"
fi

- name: Prepare release branch
Expand All @@ -119,26 +114,32 @@ jobs:
NEW_VERSION: ${{ steps.bump.outputs.new_version }}
run: |
python3 - <<'PY'
try:
import os, re, sys, glob, pathlib

current_version = os.environ["CURR_VERSION"]
new_version = os.environ["NEW_VERSION"]


print(f"current={current_version} new={new_version}")

# negative lookbehind (word,., or -) + optional 'v' + the escaped current version + negative lookahead (word or .)
# e.g. current version of 1.0.1 will match 1.0.1, v1.0.1, v1.0.1-rc.1
# e.g. current version of 1.0.1 will not match ver1.0.1, 1.0.1x, 1.0.11, 1.0.1.beta
pat = re.compile(rf'(?<![\w.-])(v?){re.escape(current_version)}(?![\w.])')

def repl(m): # preserve 'v' prefix if it existed
return (m.group(1) or '') + new_version

# Targets to update
targets = [
"scripts/nix/install.sh", # nix shell script
"scripts/windows/install.ps1", # PowerShell
*glob.glob("**/*.mdx", recursive=True), # docs
]


print(targets)
print(f"Scanning {len(targets)} targets…")

changed = 0
for path in targets:
p = pathlib.Path(path)
Expand All @@ -150,9 +151,14 @@ jobs:
p.write_text(new_txt, encoding="utf-8")
print(f"Updated {path} ({n} occurrence{'s' if n!=1 else ''})")
changed += n

if changed == 0:
sys.exit("::warning::No occurrences of the current version were found.")
print("::error::No occurrences of the current version were found.", file=sys.stderr)
sys.exit(1)
except Exception:
import traceback
traceback.print_exc()
sys.exit(1)
PY

- name: Push changes to release branch
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ on:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"
workflow_dispatch:
inputs:
inputs: &release_inputs
version:
description: Version to publish
required: true
type: string
workflow_call:
inputs: *release_inputs

env:
REGISTRY: ghcr.io
Expand Down