Repository navigation
107 lines (96 loc) · 4.5 KB
/
Copy pathsync-dev.yml
File metadata and controls
107 lines (96 loc) · 4.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Sync dev with main and bump
# Fires after a stable release publishes to npm successfully. Merges main
# back into dev and bumps dev to <next-patch>-dev0 so feature branches off
# dev never collide with the just-released version.
#
# Trigger: Publish to npm completes successfully on a v* tag (i.e. a stable
# release tag pushed by auto-tag.yml after main is updated). Branch-only
# publishes (dev, feature) are filtered out by the head_branch check below.
on:
workflow_run:
workflows: ["Publish to npm"]
types: [completed]
# No `branches:` filter, on purpose. A run triggered by a tag reports the tag name
# as its head branch, which the job's `if:` below tests, but GitHub documents the
# trigger's filter only for branches and nobody has shown it to match a tag-triggered
# run. If it did not, the release would start no sync at all: dev would stay at the
# old -devN, below the released version, and the next release's auto-tag would
# refuse to tag. What the filter bought was fewer skipped runs, which cost no runner
# minutes. Restore it only after a throwaway tag has shown that it matches.
permissions:
contents: write
jobs:
sync:
# Only run when:
# 1. The upstream publish succeeded.
# 2. The upstream was triggered by a v* tag — either via the natural
# tag-push or via the workflow_dispatch escape hatch with a v*
# ref. Branch pushes (event=push, head_branch=dev) are filtered
# out by the v* prefix check.
if: >
github.event.workflow_run.conclusion == 'success' &&
startsWith(github.event.workflow_run.head_branch, 'v') &&
(github.event.workflow_run.event == 'push' || github.event.workflow_run.event == 'workflow_dispatch')
runs-on: ubuntu-latest
# p95 16 s (50 green runs to 2026-10-13); 10 is the floor.
timeout-minutes: 10
steps:
- name: Checkout dev
uses: actions/checkout@v4
with:
ref: dev
fetch-depth: 0
# AUTO_TAG_PAT (already used by auto-tag.yml) lets us push to dev
# without tripping branch protection or workflow-trigger limits
# that the default GITHUB_TOKEN imposes on its own commits.
token: ${{ secrets.AUTO_TAG_PAT }}
- name: Configure git identity
run: |
git config user.name "nemar-bot"
git config user.email "nemar-bot@users.noreply.github.com"
- name: Validate trigger tag matches a real release
id: tag
run: |
TAG="${{ github.event.workflow_run.head_branch }}"
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# Defensive gate: a real stable release tag never trips this, so any
# ::warning:: here is something the human should look at (mistagged
# release, branch named v*, etc.). ::notice:: would hide in step logs.
echo "::warning::head_branch '$TAG' is not a stable release tag (expected vX.Y.Z); skipping sync."
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "skip=false" >> "$GITHUB_OUTPUT"
- name: Merge main into dev
if: steps.tag.outputs.skip != 'true'
run: |
git fetch origin main
# Regular merge (no fast-forward) preserves the release commit
# graph and matches the project's "dev -> main uses --merge" rule
# in reverse. A hotfix released from main conflicts with dev on the
# two version files only, so the script resolves package.json and
# backend/package.json to main's side; the next step bumps dev. Any
# other conflict aborts the merge and fails the run for a person.
scripts/ci/sync-dev-merge.sh "chore: sync dev with main after ${{ steps.tag.outputs.tag }}"
- name: Setup Bun
if: steps.tag.outputs.skip != 'true'
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.3
- name: Install dependencies
if: steps.tag.outputs.skip != 'true'
run: bun install
- name: Bump dev to next-patch-dev0
if: steps.tag.outputs.skip != 'true'
env:
# bump-version.sh -> git commit triggers husky pre-commit which
# runs root + backend typecheck. Backend deps are not installed
# here and the bump is mechanical, so disable husky.
HUSKY: '0'
run: |
./scripts/bump-version.sh dev0
- name: Push dev
if: steps.tag.outputs.skip != 'true'
run: |
git push origin dev