Skip to content

Commit

Permalink
Modify workflow for deploying package
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallku committed Nov 18, 2024
1 parent c605d4d commit 86857cb
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 92 deletions.
75 changes: 0 additions & 75 deletions .github/workflows/create-release.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .github/workflows/npm-publish.yml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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 }}

0 comments on commit 86857cb

Please sign in to comment.