-
-
Notifications
You must be signed in to change notification settings - Fork 0
Merge back to dev #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,214 @@ | ||||||||||||||||||||||||||
| # One-click release pipeline: dev -> main -> version bump -> tag -> release build. | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # Replaces the manual 13-step process: | ||||||||||||||||||||||||||
| # 1. Merges dev into main (fast-forward or merge commit) | ||||||||||||||||||||||||||
| # 2. Bumps version on main | ||||||||||||||||||||||||||
| # 3. Pushes annotated tag vX.Y.Z (triggers release.yml) | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # After release.yml completes, its sync-dev job auto-merges main back to dev. | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # Prerequisites: | ||||||||||||||||||||||||||
| # - Secret: RELEASE_AUTOMATION_PAT (fine-grained PAT: Contents + Pull requests RW) | ||||||||||||||||||||||||||
| # - Secret: TAURI_SIGNING_PRIVATE_KEY (for release.yml) | ||||||||||||||||||||||||||
| # - Optional var: RELEASE_ALLOWED_ACTORS (comma-separated usernames) | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # The existing release-bump.yml and release-tag.yml still work as manual fallbacks. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| name: Release — one-click pipeline | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||
| inputs: | ||||||||||||||||||||||||||
| release_type: | ||||||||||||||||||||||||||
| description: "Semver bump type (see https://semver.org)" | ||||||||||||||||||||||||||
| type: choice | ||||||||||||||||||||||||||
| required: true | ||||||||||||||||||||||||||
| default: patch | ||||||||||||||||||||||||||
| options: | ||||||||||||||||||||||||||
| - patch | ||||||||||||||||||||||||||
| - minor | ||||||||||||||||||||||||||
| - major | ||||||||||||||||||||||||||
| dry_run: | ||||||||||||||||||||||||||
| description: "Dry run — show what would happen without pushing" | ||||||||||||||||||||||||||
| type: boolean | ||||||||||||||||||||||||||
| default: false | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||
| contents: write | ||||||||||||||||||||||||||
| pull-requests: write | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| concurrency: | ||||||||||||||||||||||||||
| group: release-pipeline | ||||||||||||||||||||||||||
| cancel-in-progress: false | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||
| release-pipeline: | ||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||
| - name: Verify release permission | ||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||
| ACTOR: ${{ github.actor }} | ||||||||||||||||||||||||||
| REPO_OWNER: ${{ github.repository_owner }} | ||||||||||||||||||||||||||
| ALLOWED_ACTORS: ${{ vars.RELEASE_ALLOWED_ACTORS }} | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||
| python3 << 'PY' | ||||||||||||||||||||||||||
| import os | ||||||||||||||||||||||||||
| actor = os.environ["ACTOR"] | ||||||||||||||||||||||||||
| owner = os.environ["REPO_OWNER"] | ||||||||||||||||||||||||||
| raw = os.environ.get("ALLOWED_ACTORS", "").strip() | ||||||||||||||||||||||||||
| if raw: | ||||||||||||||||||||||||||
| allowed = [x.strip() for x in raw.split(",") if x.strip()] | ||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||
| allowed = [owner] | ||||||||||||||||||||||||||
| if actor not in allowed: | ||||||||||||||||||||||||||
| print(f"::error::User '{actor}' is not allowed to run releases. " | ||||||||||||||||||||||||||
| f"Allowed: {allowed}. Set repository variable RELEASE_ALLOWED_ACTORS.") | ||||||||||||||||||||||||||
| raise SystemExit(1) | ||||||||||||||||||||||||||
| print(f"OK: {actor} is authorized to release.") | ||||||||||||||||||||||||||
| PY | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Require automation PAT | ||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||
| RELEASE_AUTOMATION_PAT: ${{ secrets.RELEASE_AUTOMATION_PAT }} | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| if [ -z "${RELEASE_AUTOMATION_PAT:-}" ]; then | ||||||||||||||||||||||||||
| echo "::error::RELEASE_AUTOMATION_PAT secret is required." | ||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Checkout repo | ||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||||||||||
| token: ${{ secrets.RELEASE_AUTOMATION_PAT }} | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Configure git | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| git config user.name "github-actions[bot]" | ||||||||||||||||||||||||||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Merge dev into main | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||
| git fetch origin main dev | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Check that dev is ahead of main | ||||||||||||||||||||||||||
| BEHIND=$(git rev-list --count origin/main..origin/dev) | ||||||||||||||||||||||||||
| if [ "$BEHIND" = "0" ]; then | ||||||||||||||||||||||||||
| echo "::warning::dev has no new commits over main. Continuing with version bump only." | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| git checkout main | ||||||||||||||||||||||||||
| git reset --hard origin/main | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Merge dev into main (non-interactive) | ||||||||||||||||||||||||||
| echo "Merging origin/dev into main..." | ||||||||||||||||||||||||||
| git merge origin/dev --no-edit -m "Merge branch 'dev' into main for release" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if [ "${{ inputs.dry_run }}" = "true" ]; then | ||||||||||||||||||||||||||
| echo "::notice::DRY RUN — would merge dev into main" | ||||||||||||||||||||||||||
| echo "Commits from dev:" | ||||||||||||||||||||||||||
| git log origin/main..HEAD --oneline | ||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| git push origin main | ||||||||||||||||||||||||||
| echo "Pushed merged main." | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Comment on lines
+111
to
+117
|
||||||||||||||||||||||||||
| echo "Commits from dev:" | |
| git log origin/main..HEAD --oneline | |
| else | |
| git push origin main | |
| echo "Pushed merged main." | |
| fi | |
| else | |
| echo "Merged dev into local main. Deferring push until after version bump/tag steps succeed." | |
| fi | |
| echo "Commits from origin/main to current HEAD:" | |
| git log origin/main..HEAD --oneline |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -407,3 +407,71 @@ jobs: | |
| gh release upload "v${VERSION}" latest.json \ | ||
| --repo "$GITHUB_REPOSITORY" \ | ||
| --clobber | ||
|
|
||
| # ── Sync main back to dev after release ───────────────────────────────── | ||
| sync-dev: | ||
| runs-on: ubuntu-latest | ||
| needs: [publish-latest-json] | ||
| if: always() && needs.publish-latest-json.result == 'success' | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.RELEASE_AUTOMATION_PAT || github.token }} | ||
|
|
||
| - name: Configure git | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Merge main into dev | ||
| env: | ||
| GH_TOKEN: ${{ secrets.RELEASE_AUTOMATION_PAT || github.token }} | ||
| run: | | ||
|
Comment on lines
+421
to
+434
|
||
| set -euo pipefail | ||
|
|
||
| # Check if dev branch exists before fetching (fetch fails if branch is missing) | ||
| if ! git ls-remote --heads origin dev | grep -q .; then | ||
| echo "::notice::No dev branch found — skipping sync." | ||
| exit 0 | ||
| fi | ||
|
|
||
| git fetch origin main dev | ||
|
|
||
| git checkout dev | ||
| git reset --hard origin/dev | ||
|
|
||
| # Check if main has anything new for dev | ||
| AHEAD=$(git rev-list --count origin/dev..origin/main) | ||
| if [ "$AHEAD" = "0" ]; then | ||
| echo "dev is already up to date with main." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Try fast-forward merge first, fall back to merge commit | ||
| if git merge origin/main --ff-only 2>/dev/null; then | ||
| echo "Fast-forwarded dev to main." | ||
| git push origin dev | ||
| elif git merge origin/main --no-edit -m "chore: sync main back to dev after release"; then | ||
| echo "Merged main into dev (merge commit)." | ||
| git push origin dev | ||
| else | ||
| echo "::warning::Auto-merge of main into dev failed (conflicts). Creating PR instead." | ||
| # Create a PR for manual resolution | ||
| BRANCH="chore/sync-main-to-dev-$(date -u +%Y%m%d-%H%M%S)-${GITHUB_RUN_ID}" | ||
| git merge --abort || true | ||
| git checkout -b "$BRANCH" origin/main | ||
| git push -u origin "$BRANCH" | ||
| gh pr create \ | ||
| --base dev \ | ||
| --head "$BRANCH" \ | ||
| --title "chore: sync main back to dev after release" \ | ||
| --body "Automated post-release sync. Main has changes (version bump + release tag) that need to be merged back into dev. Resolve any conflicts and merge." | ||
| fi | ||
|
|
||
| - name: Summary | ||
| run: echo "### main synced back to dev" >> "$GITHUB_STEP_SUMMARY" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This merge step doesn’t handle conflicts beyond failing the job. Since this workflow is meant to be “one-click”, consider detecting merge conflicts and switching to a PR-based flow (similar to
sync-devinrelease.yml) so the pipeline can still complete with a clear next action instead of leaving a failed run.