Modify workflow for deploying package #1
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 package | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
check-version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.check.outputs.version }} | |
steps: | |
- name: Check version change | |
id: check | |
uses: marshallku/actions/version/check-npm@master | |
create-tag-release: | |
runs-on: ubuntu-latest | |
needs: ["check-version"] | |
if: ${{ needs.check-version.outputs.version != '' }} | |
outputs: | |
tag-exists: ${{ steps.create-tag.outputs.tag_exists }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Generate body | |
id: generate-body | |
run: | | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
git_logs=$(git log "$(git describe --tags --abbrev=0)"..HEAD --oneline) | |
git_logs="${git_logs//$'\n'/$'\n'- }" | |
{ | |
echo "body<<$EOF" | |
echo "- $git_logs" | |
echo "$EOF" | |
} >>"$GITHUB_OUTPUT" | |
shell: bash | |
- uses: rickstaa/action-create-tag@v1 | |
id: create-tag | |
with: | |
tag: ${{ needs.check-version.outputs.version }} | |
tag_exists_error: true | |
message: ${{ needs.check-version.outputs.version }} | |
- name: Create a GitHub release | |
if: ${{ steps.create-tag.outputs.tag_exists == 'false' }} | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ needs.check-version.outputs.version }} | |
name: ${{ needs.check-version.outputs.version }} | |
body: ${{ steps.generate-body.outputs.body }} | |
publish: | |
runs-on: ubuntu-latest | |
needs: ["check-version", "create-tag-release"] | |
if: ${{ needs.check-version.outputs.version != '' && needs.create-tag-release.outputs.tag-exists == 'false' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: marshallku/actions/setup/pnpm@master | |
- run: pnpm publish --access=public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |