diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 48ee413..0401538 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,3 +19,25 @@ jobs: - run: yarn lint - run: git diff --exit-code - run: yarn build + - id: detect_version_change + name: Detect version change + if: github.ref == 'refs/heads/develop' + run: | + git fetch --prune --unshallow + LATEST_TAG=$(git describe --tags --abbrev=0) + PREVIOUS_VERSION=$(git show ${LATEST_TAG}:package.json | jq -r '.version') + CURRENT_VERSION=$(cat package.json | jq -r '.version') + if [ "$PREVIOUS_VERSION" != "$CURRENT_VERSION" ]; then + echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION" + echo "VERSION_CHANGED=true" >> $GITHUB_ENV + echo "PACKAGE_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV + else + echo "Version did not change" + fi + - name: Tag version + if: env.VERSION_CHANGED == 'true' + run: | + git config user.name "$(git log -1 --pretty=format:'%an')" + git config user.email "$(git log -1 --pretty=format:'%ae')" + git tag v${PACKAGE_VERSION} + git push origin v${PACKAGE_VERSION}