Skip to content

Commit

Permalink
🐞 fix(workflow): 如果提交,默认未修改
Browse files Browse the repository at this point in the history
  • Loading branch information
marherb committed May 4, 2024
1 parent d682140 commit 93e0718
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

0 comments on commit 93e0718

Please sign in to comment.