Skip to content

Merge pull request #18 from saranagaoka/branch #45

Merge pull request #18 from saranagaoka/branch

Merge pull request #18 from saranagaoka/branch #45

Workflow file for this run

name: Create Tag
on:
push:
branches:
- master
- prod
- dev
jobs:
build:
name: Create Tag
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Bump version and push tag
env:
GITHUB_REF: ${{ github.ref }}
run: |
git fetch --tags
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
IFS='.' read -ra VERSION_PARTS <<< "${TAG:1}"
MAJOR=${VERSION_PARTS[0]}
MINOR=${VERSION_PARTS[1]}
PATCH=${VERSION_PARTS[2]}
case "${GITHUB_REF}" in
'refs/heads/prod')
MAJOR=$((MAJOR + 1))
;;
'refs/heads/dev')
MINOR=$((MINOR + 1))
;;
'refs/heads/master')
PATCH=$((PATCH + 1))
;;
esac
NEW_TAG="v$MAJOR.$MINOR.$PATCH"
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
git config --global user.email "[email protected]"
git config --global user.name "GitHub Action"
git tag $NEW_TAG
git push origin $NEW_TAG