Merge pull request #2 from placia/develop #2
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: Tag Release | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
create-tag: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Extract version from commit title | |
id: extract_version | |
run: | | |
# Get the latest commit message | |
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
# Extract version assuming it's in format like "release v1.0.0" | |
if [[ $COMMIT_MESSAGE =~ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then | |
VERSION="${BASH_REMATCH[1]}" | |
echo "Version found: $VERSION" | |
echo "::set-output name=version::$VERSION" | |
else | |
echo "No version found in commit message." | |
exit 1 | |
fi | |
- name: Create tag | |
if: success() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git tag -a "v${{ steps.extract_version.outputs.version }}" -m "Release ${{ steps.extract_version.outputs.version }}" | |
git push origin "v${{ steps.extract_version.outputs.version }}" | |