update release worker action #5
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: Create Tag and Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.GHCR_PAT }} | |
- name: Set up Git | |
run: | | |
git config --global user.name ${{ secrets.GIT_USER_NAME }} | |
git config --global user.email ${{ secrets.GIT_USER_EMAIL }} | |
- name: Get current version | |
run: | | |
set -e # Fail on first error | |
# Extract the latest tag, or default to v1.0.0 | |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1` || echo "v1.0.0") | |
echo "Latest tag: $latest_tag" | |
echo "latest_tag=$latest_tag" >> $GITHUB_ENV | |
# Split the tag into parts | |
IFS='.' read -r -a parts <<< "${latest_tag//v/}" | |
major=${parts[0]} | |
minor=${parts[1]} | |
patch=${parts[2]} | |
# Increment the patch version | |
new_patch=$((patch + 1)) | |
new_tag="v$major.$minor.$new_patch" | |
echo "New tag: $new_tag" | |
echo "new_tag=$new_tag" >> $GITHUB_ENV | |
- name: Create new tag | |
run: | | |
set -e # Fail on first error | |
git tag ${{ env.new_tag }} | |
git push origin ${{ env.new_tag }} | |
- name: Create GitHub release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GHCR_PAT }} | |
with: | |
tag_name: ${{ env.new_tag }} | |
release_name: ${{ env.new_tag }} | |
body: "Automated release for tag ${{ env.new_tag }}" | |
draft: false | |
prerelease: false |