Skip to content

Commit 3fe5f99

Browse files
committed
Release workflow: don't commit directly to main
1 parent f3a1010 commit 3fe5f99

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

.github/workflows/release-branch.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979

8080
permissions:
8181
contents: write
82+
pull-requests: write
8283

8384
needs: [tag, compute-version, localazy]
8485
steps:
@@ -102,3 +103,14 @@ jobs:
102103
sha,
103104
});
104105
console.log(`Created branch ${branch} from ${sha}`);
106+
107+
- name: Open a pull request to merge the branch into main
108+
env:
109+
VERSION: ${{ needs.compute-version.outputs.short }}
110+
run: |
111+
gh pr create \
112+
--title "Release branch $VERSION" \
113+
--body "This pull request was automatically created by the release workflow. It merges the release branch back to main." \
114+
--base main \
115+
--head "release/v$VERSION" \
116+
--label "T-Task"

.github/workflows/release-bump.yaml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,38 @@ jobs:
5454
secrets:
5555
BOT_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
5656

57-
merge-back:
58-
name: Open a pull request to merge the release branch back to main
57+
update-branch:
58+
name: Update the release branch
5959
runs-on: ubuntu-22.04
6060

6161
permissions:
6262
pull-requests: write
6363

6464
needs: [tag, compute-version]
65-
if: github.event.inputs.merge-back
6665
steps:
66+
- name: Update the release branch
67+
uses: actions/github-script@v7.0.1
68+
env:
69+
BRANCH: "${{ github.ref_name }}"
70+
SHA: ${{ needs.tag.outputs.sha }}
71+
with:
72+
github-token: ${{ secrets.BOT_GITHUB_TOKEN }}
73+
script: |
74+
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
75+
const branch = process.env.BRANCH;
76+
const sha = process.env.SHA;
77+
const ref = `refs/heads/${branch}`;
78+
79+
await github.rest.git.updateRef({
80+
owner,
81+
repo,
82+
ref,
83+
sha,
84+
});
85+
console.log(`Updated branch ${branch} to ${sha}`);
86+
6787
- name: Open a pull request to merge the release branch back to main
88+
if: github.event.inputs.merge-back
6889
env:
6990
VERSION: ${{ needs.compute-version.outputs.version }}
7091
run: |

.github/workflows/tag.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ jobs:
4646
working-directory: tools/syn2mas
4747
run: npm version "${{ inputs.version }}" --no-git-tag-version
4848

49-
- name: Re-format package.json with biome
50-
working-directory: tools/syn2mas
51-
run: npx biome format --write package.json
52-
5349
- name: Commit and tag using the GitHub API
5450
uses: actions/github-script@v7.0.1
5551
id: commit
@@ -142,11 +138,3 @@ jobs:
142138
sha: tagSha,
143139
});
144140
console.log("Created tag ref:", tag.data.url);
145-
146-
const ref = await github.rest.git.updateRef({
147-
owner,
148-
repo,
149-
ref: `heads/${branch}`,
150-
sha: commit,
151-
});
152-
console.log("Updated branch ref:", ref.data.url);

0 commit comments

Comments
 (0)