diff --git a/.github/workflows/auto-tag.yaml b/.github/workflows/auto-tag.yaml new file mode 100644 index 0000000..d72d2bf --- /dev/null +++ b/.github/workflows/auto-tag.yaml @@ -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" diff --git a/Makefile b/Makefile index 16718dc..4545005 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/RELEASE.md b/RELEASE.md index 1564ef0..bae13c5 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -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