Skip to content

Commit

Permalink
Fix tag action script
Browse files Browse the repository at this point in the history
  • Loading branch information
giggio committed Sep 22, 2023
1 parent 13b621c commit afe9bf9
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,39 @@ jobs:
name: Create tag
with:
script: |
const tag = octokit.rest.git.getRef({
const tag = await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/${{ steps.version.outputs.NEW_VERSION }}',
ref: 'tags/${{ steps.version.outputs.VERSION }}'
});
if (tag == null || tag.status == 404)
if (tag != null && tag.status == 200) {
console.error('Tag ${{ steps.version.outputs.VERSION }} already exists.');
return;
const createdTag = github.rest.git.createTag({
}
const main = await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'heads/main'
});
const createdTag = await github.rest.git.createTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: ${{ steps.version.outputs.NEW_VERSION }},
message: 'Bump version to ${{ steps.version.outputs.NEW_VERSION }}',
object: context.sha,
tag: '${{ steps.version.outputs.VERSION }}',
message: 'Bump version to ${{ steps.version.outputs.VERSION }}',
object: main.data.object.sha,
type: 'commit'
});
if (createdTag.status !== 201) {
console.error(`Could not create tag ${{ steps.version.outputs.NEW_VERSION }}.`);
console.error('Could not create tag ${{ steps.version.outputs.VERSION }}.');
}
const createdRef = github.rest.git.createRef({
const createdRef = await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.version.outputs.NEW_VERSION }}',
ref: 'refs/tags/${{ steps.version.outputs.VERSION }}',
sha: createdTag.data.sha
});
if (createdRef.status === 201) {
console.log(`Tag ${{ steps.version.outputs.NEW_VERSION }} was created successfully`);
console.log('Tag ${{ steps.version.outputs.VERSION }} was created successfully');
} else {
console.error(`Could not create ref ${{ steps.version.outputs.NEW_VERSION }}.`);
console.error('Could not create ref ${{ steps.version.outputs.VERSION }}.');
}

0 comments on commit afe9bf9

Please sign in to comment.