-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): add ci for publishing package on version changed
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
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,51 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- name: Install dependencies | ||
run: yarn | ||
|
||
- name: Build package | ||
run: yarn build | ||
|
||
- name: Check if version has changed | ||
id: version_check | ||
run: | | ||
# Get the current version from package.json | ||
current_version=$(jq -r '.version' package.json) | ||
# Get the previous version from the last commit | ||
git fetch --depth=2 | ||
previous_version=$(git show HEAD^1:package.json | jq -r '.version') | ||
echo "Current version: $current_version" | ||
echo "Previous version: $previous_version" | ||
if [ "$current_version" != "$previous_version" ]; then | ||
echo "::set-output name=version_changed::true" | ||
else | ||
echo "::set-output name=version_changed::false" | ||
fi | ||
- name: Publish to NPM | ||
if: steps.version_check.outputs.version_changed == 'true' | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_CI_TOKEN }} | ||
run: npm publish --dry-run |