Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/scripts/update-major-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// @ts-check

/** @param {import('@actions/github-script').AsyncFunctionArguments} args */
module.exports = async ({ github, context }) => {
Comment thread
erezrokah marked this conversation as resolved.
Outdated
const tag = context.payload.release?.tag_name;
Comment thread
erezrokah marked this conversation as resolved.
if (!tag) {
throw new Error("No release tag found in event payload");
}

const match = tag.match(/^(v\d+)\.\d+\.\d+/);
if (!match) {
throw new Error(`Tag "${tag}" does not match semver pattern vX.Y.Z`);
}

const majorTag = match[1];
const sha = context.sha;

const tagsToUpdate = [majorTag, "latest"];

for (const tagName of tagsToUpdate) {
const ref = `tags/${tagName}`;
try {
await github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref,
sha,
force: true,
});
console.log(`Updated ${ref} to ${sha}`);
} catch (error) {
if (error.status === 422) {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/${ref}`,
sha,
});
Comment thread
erezrokah marked this conversation as resolved.
console.log(`Created ${ref} at ${sha}`);
} else {
throw error;
}
}
}
};
8 changes: 5 additions & 3 deletions .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ jobs:
actions-tagger:
runs-on: ubuntu-latest
steps:
- uses: Actions-R-Us/actions-tagger@148653c6179832f8392d083de6b46ad3dcc54de3
- uses: actions/checkout@v4
Comment thread
erezrokah marked this conversation as resolved.
Outdated
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
publish_latest_tag: true
token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fn = require('./.github/scripts/update-major-tag.js');
Comment thread
erezrokah marked this conversation as resolved.
Outdated
await fn({ github, context });
Loading