-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: skip publish when there is no update to package version
- Loading branch information
1 parent
194e328
commit 3be6861
Showing
3 changed files
with
55 additions
and
78 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- v1.X | ||
|
||
jobs: | ||
run-publish: | ||
name: Run publish | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
actions: write | ||
|
||
steps: | ||
- name: Check out git repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
cache: 'yarn' | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- name: Install yarn dependencies | ||
run: yarn install | ||
|
||
- name: Build | ||
run: yarn build | ||
|
||
- name: Test | ||
run: yarn test | ||
|
||
- name: Check version and publish | ||
run: | | ||
PACKAGE_NAME=$(node -p "require('./package.json').name") | ||
CURRENT_VERSION=$(node -p "require('./package.json').version") | ||
# Check if version exists in npm registry | ||
if npm view "${PACKAGE_NAME}@${CURRENT_VERSION}" version &>/dev/null; then | ||
echo "Version $CURRENT_VERSION already published, skipping" | ||
exit 0 | ||
fi | ||
if [[ "$CURRENT_VERSION" =~ (next) ]]; then | ||
yarn publish:next | ||
else | ||
yarn publish:latest | ||
fi | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |