-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AbigailDeng
authored and
AbigailDeng
committed
Jul 23, 2024
1 parent
2995bed
commit 10510a4
Showing
1 changed file
with
45 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,45 @@ | ||
name: publish | ||
env: | ||
CI: true | ||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- '!*' | ||
jobs: | ||
release: | ||
name: Setup | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v2 | ||
- name: setup Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 18.x | ||
registry-url: 'https://npm.pkg.github.com' | ||
- name: install | ||
run: yarn install | ||
- name: lint | ||
run: npm lint | ||
# Publish to npm if this version is not published | ||
- name: publish | ||
run: | | ||
npx can-npm-publish --verbose | ||
npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN | ||
npm publish || (echo "npm publish failed" && exit 1) | ||
env: | ||
NPM_TOKEN: ${{secrets.NPM_TOKEN}} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# Push tag to GitHub if package.json version's tag is not tagged | ||
- name: package-version | ||
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV | ||
- name: package-version-to-git-tag | ||
uses: pkgdeps/git-tag-action@v2 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
github_repo: ${{ github.repository }} | ||
version: ${{ env.PACKAGE_VERSION }} | ||
git_commit_sha: ${{ github.sha }} | ||
git_tag_prefix: 'v' |