Skip to content

Commit

Permalink
feat(ci): Add autotag workflow
Browse files Browse the repository at this point in the history
This simplify release without having to do manual tags

Signed-off-by: Alexander Gil <[email protected]>
  • Loading branch information
pando85 committed Jun 21, 2024
1 parent 1f81feb commit 2ed574e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/workflows/auto-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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
run: |
tag=${{ steps.changelog_reader.outputs.version }}
if git ls-remote --tags origin | grep -q "refs/tags/$tag"; then
echo "Tag already exists"
echo "TAG_EXISTS=true" >> $GITHUB_ENV
else
echo "Tag does not exist"
echo "TAG_EXISTS=false" >> $GITHUB_ENV
fi
- name: Import GPG key
if: env.TAG_EXISTS == 'false'
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
- name: Create new tag
if: env.TAG_EXISTS == 'false'
run: |
tag=${{ 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 "$tag" -m "$tag" --local-user $(gpg --list-keys --with-colons | grep '^pub' | cut -d':' -f5)
git push origin "$tag"
1 change: 0 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
- Update lock file: `cargo update -p rash_core -p rash_derive`.
- Update `CHANGELOG.md` with `make update-changelog`.
- Merge PR.
- Tag version in master branch: `make tag`.

## Upgrade dependencies

Expand Down

0 comments on commit 2ed574e

Please sign in to comment.