Skip to content

Commit

Permalink
ci: Add auto-tag.yaml github action
Browse files Browse the repository at this point in the history
  • Loading branch information
pando85 committed Jun 18, 2024
1 parent 366de1b commit cf32540
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/auto-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Auto tag

on:
push:
branches:
- main

jobs:
tag:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
with:
token: ${{ secrets.PAT }}
uses: actions/checkout@v4

- name: Get last changelog version
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
path: ./CHANGELOG.md

- name: Check if tag exists
id: check_tag
run: |
version=${{ steps.changelog_reader.outputs.version }}
if git rev-parse "$version" >/dev/null 2>&1; then
echo "Tag already exists"
echo "::set-output name=tag_exists::true"
else
echo "Tag does not exist"
echo "::set-output name=tag_exists::false"
fi
- name: Import GPG key
if: steps.check_tag.outputs.tag_exists == 'false'
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
- name: Create new tag
if: steps.check_tag.outputs.tag_exists == 'false'
run: |
version=${{ steps.changelog_reader.outputs.version }}
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git tag -s "$version" -m "$version" --local-user $(gpg --list-keys --with-colons | grep '^pub' | cut -d':' -f5)
git push origin "$version"
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,3 @@ delete-kind:
.PHONY: update-changelog
update-changelog:
git cliff -t v$(VERSION) -u -p CHANGELOG.md

.PHONY: tag
tag:
git tag -s v$(VERSION) -m "v$(VERSION)" && \
git push origin v$(VERSION)
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

- Update `CHANGELOG.md` with `VERSION=X.Y.Z make update-changelog`
- Merge PR
- Tag version in main branch: `VERSION=X.Y.Z make tag`
- Tag version is automatically done

0 comments on commit cf32540

Please sign in to comment.