Skip to content

Commit 3c68ee6

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 3c68ee6

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

.github/workflows/tag-version.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
permissions:
11+
contents: write
12+
steps:
13+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
14+
15+
- name: Check version
16+
id: check
17+
run: |
18+
VERSION=$(ruby -e "require './lib/aws_lambda_ric/version'; puts AwsLambdaRIC::VERSION")
19+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
20+
if git rev-parse "refs/tags/$VERSION" >/dev/null 2>&1; then
21+
echo "tag_exists=true" >> "$GITHUB_OUTPUT"
22+
else
23+
echo "tag_exists=false" >> "$GITHUB_OUTPUT"
24+
fi
25+
26+
- name: Create tag
27+
if: steps.check.outputs.tag_exists == 'false'
28+
run: |
29+
git tag ${{ steps.check.outputs.version }}
30+
git push origin ${{ steps.check.outputs.version }}

0 commit comments

Comments
 (0)