test/create tag with diff package.json version #12
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: version | |
on: | |
push: | |
branches: [master] | |
paths: ['package.json'] | |
jobs: | |
tags: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: diff package.json version | |
id: version | |
run: | | |
previous=$(git show HEAD^:package.json | grep '"version"' | awk -F '"' '{print $4}') | |
current=$(git show HEAD:package.json | grep '"version"' | awk -F '"' '{print $4}') | |
echo "previous=v$previous" >> $GITHUB_OUTPUT | |
echo "current=v$current" >> $GITHUB_OUTPUT | |
- name: create tag with package.json version | |
if: steps.version.outputs.previous != steps.version.outputs.current | |
run: | | |
git tag ${{ steps.version.outputs.current }} | |
git push origin ${{ steps.version.outputs.current }} |