Skip to content

Commit 590f14a

Browse files
committed
[ci] Create long‑lived maintenance branch after release published
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent 4c8dba8 commit 590f14a

2 files changed

Lines changed: 30 additions & 26 deletions

File tree

‎.github/workflows/pull-requests-release.yaml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,36 @@ jobs:
7676
git tag -f ${{ steps.get_tag.outputs.tag }} ${{ github.sha }}
7777
git push -f origin ${{ steps.get_tag.outputs.tag }}
7878
79+
# Ensure maintenance branch release-X.Y
80+
- name: Ensure maintenance branch release-X.Y
81+
uses: actions/github-script@v7
82+
with:
83+
script: |
84+
const tag = '${{ steps.get_tag.outputs.tag }}'; // e.g. v0.1.3 or v0.1.3-rc3
85+
const match = tag.match(/^v(\d+)\.(\d+)\.\d+(?:[-\w\.]+)?$/);
86+
if (!match) {
87+
core.setFailed(`❌ tag '${tag}' must match 'vX.Y.Z' or 'vX.Y.Z-suffix'`);
88+
return;
89+
}
90+
const line = `${match[1]}.${match[2]}`;
91+
const branch = `release-${line}`;
92+
try {
93+
await github.rest.repos.getBranch({
94+
owner: context.repo.owner,
95+
repo: context.repo.repo,
96+
branch
97+
});
98+
console.log(`Branch '${branch}' already exists`);
99+
} catch (_) {
100+
await github.rest.git.createRef({
101+
owner: context.repo.owner,
102+
repo: context.repo.repo,
103+
ref: `refs/heads/${branch}`,
104+
sha: context.sha
105+
});
106+
console.log(`✅ Branch '${branch}' created at ${context.sha}`);
107+
}
108+
79109
# Get the latest published release
80110
- name: Get the latest published release
81111
id: latest_release

‎.github/workflows/tags.yaml‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -178,32 +178,6 @@ jobs:
178178
env:
179179
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
180180

181-
# Ensure long‑lived maintenance branch release‑X.Y
182-
- name: Ensure maintenance branch release‑${{ steps.tag.outputs.line }}
183-
if: |
184-
steps.check_release.outputs.skip == 'false' &&
185-
steps.get_base.outputs.branch == 'main'
186-
uses: actions/github-script@v7
187-
with:
188-
script: |
189-
const branch = `release-${'${{ steps.tag.outputs.line }}'}`;
190-
try {
191-
await github.rest.repos.getBranch({
192-
owner: context.repo.owner,
193-
repo: context.repo.repo,
194-
branch
195-
});
196-
console.log(`Branch '${branch}' already exists`);
197-
} catch (_) {
198-
await github.rest.git.createRef({
199-
owner: context.repo.owner,
200-
repo: context.repo.repo,
201-
ref: `refs/heads/${branch}`,
202-
sha: context.sha
203-
});
204-
console.log(`Branch '${branch}' created at ${context.sha}`);
205-
}
206-
207181
# Create release‑X.Y.Z branch and push (force‑update)
208182
- name: Create release branch
209183
if: steps.check_release.outputs.skip == 'false'

0 commit comments

Comments
 (0)