File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 }}'; // v0.31.5
85+ const match = tag.match(/^v(\d+)\.(\d+)\.\d+/);
86+ if (!match) {
87+ core.setFailed(`❌ tag '${tag}' must match 'vX.Y.Z'`);
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
Original file line number Diff line number Diff 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'
You can’t perform that action at this time.
0 commit comments