diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 05e4077..1d9771d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,30 +24,26 @@ jobs: - name: Check package.json version change id: check_version run: | - VERSION_IN_GIT=$(git diff HEAD~ -- package.json | grep -oP '(?<="version": ")[^"]*' || :) - if [ -z "$VERSION_IN_GIT" ]; then - echo "Unable to find previous version info or no previous commit." - VERSION_IN_GIT="None" - fi + VERSION_IN_GIT=$(git diff HEAD~ -- package.json | grep -oP '(?<="version": ")[^"]*' || echo "not_found") CURRENT_VERSION=$(node -p "require('./package.json').version") - if [ "$VERSION_IN_GIT" == "$CURRENT_VERSION" ]; then - echo "Version has not changed." - echo "::set-output name=version_changed::false" + if [ "$VERSION_IN_GIT" == "$CURRENT_VERSION" ] || [ "$VERSION_IN_GIT" == "not_found" ]; then + echo "Version has not changed or unable to find previous version info." + echo "version_changed=false" >> $GITHUB_ENV else echo "Version has changed." - echo "::set-output name=version_changed::true" + echo "version_changed=true" >> $GITHUB_ENV fi - name: Install dependencies - if: steps.check_version.outputs.version_changed == 'true' + if: env.version_changed == 'true' run: yarn install - name: Build package - if: steps.check_version.outputs.version_changed == 'true' + if: env.version_changed == 'true' run: yarn build - name: Publish to NPM - if: steps.check_version.outputs.version_changed == 'true' + if: env.version_changed == 'true' run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file