Skip to content

Merge pull request #21 from saranagaoka/pies #53

Merge pull request #21 from saranagaoka/pies

Merge pull request #21 from saranagaoka/pies #53

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))
MINOR=0
PATCH=0
;;
'refs/heads/dev')
MINOR=$((MINOR + 1))
PATCH=0
;;
*)
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