Files
psysonic/.github/workflows/promote-main-to-next.yml
cucadmuh a9573625f4 ci(release): gate promote-main on explicit main checks (#349)
* ci(release): gate promote-main on explicit main checks

Add an always-on ci-main workflow that produces a stable check name, and validate that check via check runs (not branch protection APIs). Wire promote-main-to-next to require ci-main / ci-ok and document the required check in the release SOP.

* ci(release): accept ci-ok or UI-style name in main promote gate

GitHub check run names for normal workflows are often the job name only;
keep optional match for the UI-style workflow/job label. Drop unused
statuses:read permission.

Made-with: Cursor
2026-04-29 00:22:51 +03:00

65 lines
2.2 KiB
YAML

name: Promote main to next
on:
workflow_dispatch:
jobs:
validate-main:
uses: ./.github/workflows/validate-main-green-ci.yml
with:
branch: main
required_contexts: ci-ok|ci-main / ci-ok
promote:
needs: validate-main
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
ref: next
- name: setup node
uses: actions/setup-node@v5
with:
node-version: lts/*
- name: fast-forward next to main
run: |
set -euo pipefail
git fetch origin main next
# Reset channel branch to main snapshot, then create a fresh RC bump commit.
git reset --hard origin/main
- name: bump package version to next RC
run: |
set -euo pipefail
git fetch --tags origin
CURRENT_VERSION="$(node -p 'require("./package.json").version')"
BASE_VERSION="$(node -p 'const v=require("./package.json").version; const m=v.match(/^(\d+\.\d+\.\d+)/); if(!m){throw new Error("Invalid version: "+v)}; m[1]')"
MAX_RC="$(git tag -l "app-v${BASE_VERSION}-rc.*" | sed -E 's/.*-rc\.([0-9]+)$/\1/' | sort -n | tail -n1)"
if [[ -z "$MAX_RC" ]]; then
NEXT_RC=1
else
NEXT_RC=$((MAX_RC + 1))
fi
TARGET_VERSION="${BASE_VERSION}-rc.${NEXT_RC}"
if [[ "$CURRENT_VERSION" == "$TARGET_VERSION" ]]; then
echo "package.json already uses $TARGET_VERSION"
exit 0
fi
npm version --no-git-tag-version "$TARGET_VERSION"
- name: commit RC version bump
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add package.json package-lock.json
if git diff --cached --quiet; then
echo "No version bump changes to commit."
exit 0
fi
NEW_VERSION="$(node -p 'require("./package.json").version')"
git commit -m "chore(release): bump next channel to ${NEW_VERSION}"
- name: push next
run: git push --force-with-lease origin HEAD:next