Skip to content

Commit b4399fb

Browse files
author
ilyasse benrkia
committed
ci: auto-tag on version bump merge
Automatically create a git tag when version.rb changes on main. Prevents tags from going missing when releases are published to rubygems via the internal CodeBuild pipeline. Closes #61
1 parent 7ae6e6c commit b4399fb

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

.github/workflows/tag-version.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Tag version on merge
2+
on:
3+
push:
4+
branches: [main]
5+
paths: ['lib/aws_lambda_ric/version.rb']
6+
7+
jobs:
8+
tag:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Check version
14+
id: check
15+
run: |
16+
VERSION=$(ruby -e "require './lib/aws_lambda_ric/version'; puts AwsLambdaRIC::VERSION")
17+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
18+
if git rev-parse "refs/tags/$VERSION" >/dev/null 2>&1; then
19+
echo "tag_exists=true" >> "$GITHUB_OUTPUT"
20+
else
21+
echo "tag_exists=false" >> "$GITHUB_OUTPUT"
22+
fi
23+
24+
- name: Create tag
25+
if: steps.check.outputs.tag_exists == 'false'
26+
run: |
27+
git tag ${{ steps.check.outputs.version }}
28+
git push origin ${{ steps.check.outputs.version }}

0 commit comments

Comments
 (0)