Skip to content

Commit

Permalink
🐞 fix(workflow): 打包时查看version版本
Browse files Browse the repository at this point in the history
  • Loading branch information
marherb committed May 4, 2024
1 parent 23fde06 commit 4083495
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,29 @@ jobs:
registry-url: 'https://registry.npmjs.org'
scope: '@marherb-work'

- name: Check package.json version change
id: check_version
run: |
VERSION_IN_GIT=$(git diff HEAD~ -- package.json | grep -oP '(?<="version": ")[^"]*')
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"
else
echo "Version has changed."
echo "::set-output name=version_changed::true"
fi
- name: Install dependencies
if: steps.check_version.outputs.version_changed == 'true'
run: yarn install

- name: Build package
if: steps.check_version.outputs.version_changed == 'true'
run: yarn build

- name: Publish to NPM
if: steps.check_version.outputs.version_changed == 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 4083495

Please sign in to comment.