Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci/add auto tags #453

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
- master

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"
Loading
Loading