にゅーすたいる (#33) #24
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 | |
on: | |
push: | |
branches: | |
- production | |
jobs: | |
create-tag: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get package version | |
id: package-version | |
run: echo "::set-output name=version::$(node -p -e "require('./package.json').version")" | |
- name: Get tag version and compare versions | |
id: tag-version | |
run: | | |
echo "::set-output name=tag::$(git describe --tags --abbrev=0)" | |
version=$(node -p -e "require('./package.json').version") | |
tag=$(git describe --tags --abbrev=0) | |
if [[ $version == $tag ]]; then | |
echo "::set-output name=compare::true" | |
else | |
echo "::set-output name=compare::false" | |
fi | |
- name: Create tag if versions have upgraded | |
if: steps.tag-version.outputs.compare == 'false' | |
run: | | |
git config --local user.name "github-actions" | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git tag -a ${{ steps.package-version.outputs.version }} -m "Production release ${{ steps.package-version.outputs.version }}" | |
git push --follow-tags |