Skip to content

Commit 2d6e50b

Browse files
committed
[ci] Fix auto-release workflow
Signed-off-by: Andrei Kvapil <[email protected]>
1 parent dea42d0 commit 2d6e50b

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

‎.github/workflows/auto-release.yaml‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,18 @@ jobs:
3636
3737
- name: Process release branches
3838
uses: actions/github-script@v7
39+
env:
40+
GH_PAT: ${{ secrets.GH_PAT }}
3941
with:
4042
github-token: ${{ secrets.GH_PAT }}
4143
script: |
4244
const { execSync } = require('child_process');
43-
45+
46+
// Configure git to use PAT for authentication
47+
execSync('git config user.name "cozystack-bot"', { encoding: 'utf8' });
48+
execSync('git config user.email "[email protected]"', { encoding: 'utf8' });
49+
execSync(`git remote set-url origin https://cozystack-bot:${process.env.GH_PAT}@github.com/${process.env.GITHUB_REPOSITORY}`, { encoding: 'utf8' });
50+
4451
// Get all release-X.Y branches
4552
const branches = execSync('git branch -r | grep -E "origin/release-[0-9]+\\.[0-9]+$" | sed "s|origin/||" | tr -d " "', { encoding: 'utf8' })
4653
.split('\n')
@@ -146,10 +153,27 @@ jobs:
146153
147154
console.log(` 🏷️ Creating new tag: ${nextTag} on commit ${latestBranchCommit}`);
148155
149-
// Create and push the tag (force push to update if exists)
156+
// Create and push the tag with base_ref for workflow triggering
150157
try {
151-
execSync(`git tag -f ${nextTag} ${latestBranchCommit}`, { encoding: 'utf8' });
152-
execSync(`git push -f origin ${nextTag}`, { encoding: 'utf8' });
158+
// Delete local tag if exists to force update
159+
try {
160+
execSync(`git tag -d ${nextTag}`, { encoding: 'utf8' });
161+
} catch (e) {
162+
// Tag doesn't exist locally, that's fine
163+
}
164+
165+
// Delete remote tag if exists
166+
try {
167+
execSync(`git push origin :refs/tags/${nextTag}`, { encoding: 'utf8' });
168+
} catch (e) {
169+
// Tag doesn't exist remotely, that's fine
170+
}
171+
172+
// Create tag locally
173+
execSync(`git tag ${nextTag} ${latestBranchCommit}`, { encoding: 'utf8' });
174+
175+
// Push tag with HEAD reference to preserve base_ref
176+
execSync(`git push origin HEAD:refs/tags/${nextTag}`, { encoding: 'utf8' });
153177
console.log(` ✅ Successfully created and pushed tag ${nextTag}`);
154178
} catch (error) {
155179
console.log(` ❌ Error creating/pushing tag ${nextTag}: ${error.message}`);

0 commit comments

Comments
 (0)