ci: add release token for tagging (#248) #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 📜 Release | Tag | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
tag-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # required for tag metadata | |
token: ${{ secrets.RELEASE_TOKEN }} # Uses a PAT to ensure subsequent workflows get triggered | |
- name: Set up Git | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Get current version | |
run: | | |
version=$(./scripts/get-version.sh) | |
echo "version=$version" >> $GITHUB_ENV | |
- name: Check if tag already exists | |
run: | | |
if git rev-parse "${{ env.version }}" >/dev/null 2>&1; then | |
echo "Tag already exists." | |
echo "exists=true" >> $GITHUB_ENV | |
else | |
echo "Tag does not exist." | |
echo "exists=false" >> $GITHUB_ENV | |
fi | |
- name: Create and push tag | |
if: env.exists == 'false' | |
run: | | |
git tag -a "${{ env.version }}" -m "Release version ${{ env.version }}" | |
git push origin "${{ env.version }}" |