chore(deps): bump nanoid from 3.3.7 to 3.3.8 in /example #198
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
name: publish | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
types: [closed] | |
env: | |
CI: true | |
jobs: | |
publish: | |
name: publish | |
runs-on: macos-latest | |
strategy: | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
registry-url: 'https://registry.npmjs.org' | |
- name : GITHUB CONTEXT | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- name: Get commit message | |
run: | | |
COMMIT_MESSAGE=$(git log --format=%s -n 1) | |
echo "commitmsg=${COMMIT_MESSAGE}" >> $GITHUB_ENV | |
- name: Show commit message | |
run : echo "$commitmsg" | |
- name: npm install, build | |
run: | | |
yarn | |
yarn prepare | |
env: | |
CI: true | |
- name: Set Current Version | |
if: startsWith( env.commitmsg , 'chore(release):' ) | |
shell: bash -ex {0} | |
run: | | |
CURRENT_VERSION=$(node -p 'require("./package.json").version') | |
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV | |
- name: Tag Check | |
if: startsWith( env.commitmsg , 'chore(release):' ) | |
id: tag_check | |
shell: bash -ex {0} | |
run: | | |
GET_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/git/ref/tags/v${CURRENT_VERSION}" | |
http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \ | |
-H "Authorization: token ${GITHUB_TOKEN}") | |
if [ "$http_status_code" -ne "404" ] ; then | |
echo "::set-output name=exists_tag::true" | |
else | |
echo "::set-output name=exists_tag::false" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Git Tag | |
if: startsWith( env.commitmsg , 'chore(release):' ) && steps.tag_check.outputs.exists_tag == 'false' | |
uses: azu/action-package-version-to-git-tag@v1 | |
with: | |
version: ${{ env.CURRENT_VERSION }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
github_repo: ${{ github.repository }} | |
git_commit_sha: ${{ github.sha }} | |
git_tag_prefix: "v" | |
- name: Create Release | |
id: create_release | |
if: startsWith( env.commitmsg , 'chore(release):' ) && steps.tag_check.outputs.exists_tag == 'false' && github.event.pull_request.merged == true | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.CURRENT_VERSION }} | |
# Copy Pull Request's title and body to Release Note | |
release_name: ${{ github.event.pull_request.title }} | |
body: | | |
${{ github.event.pull_request.body }} | |
draft: false | |
prerelease: false | |
- name: npm publish | |
if: steps.tag_check.outputs.exists_tag == 'false' && startsWith( env.commitmsg , 'chore(release):' ) | |
run: npm publish --access public | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |