Skip to content

Commit

Permalink
📦 ci(.github): fixed npm publish and release please actions to releas…
Browse files Browse the repository at this point in the history
…e when PR is merged
  • Loading branch information
prjctimg committed Apr 6, 2024
1 parent 75a6b9f commit 30628a5
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 20 deletions.
49 changes: 29 additions & 20 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,32 @@ on:
branches:
- main
jobs:
- name: Publish to NPM
# The logic below handles the npm publication:
- uses: actions/checkout@v4
# these if statements ensure that a publication only occurs when
# a new release is created:
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.release_created }}
- run: npm i
if: ${{ steps.release.outputs.release_created }}
- run: |
npm test
npm run code:publish
npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH}}
if: ${{ steps.release.outputs.release_created }}
name: NPM package


on :
release:
types:[created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm i && npm run code:publish

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm i && npm test
env:
NPM_TOKEN: ${{secrets.NPM_PUBLISH}}
31 changes: 31 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,34 @@ jobs:
id: release
with:
release-type: node
package-name: release-please-action
- name: Checkout repo
# The logic below handles the npm publication:
- uses: actions/checkout@v4
# these if statements ensure that a publication only occurs when
# a new release is created:
if: ${{ steps.release.outputs.release_created }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20

if: ${{ steps.release.outputs.release_created }}
- name: Creating .npmrc
- run: npm i
if: ${{ steps.release.outputs.release_created }}
- run: |
cat << EOF > "$HOME/.npmrc" //registry.npmjs.org/:_authToken=$NPM_PUBLISH EOF
env:
NPM_TOKEN:${{secrets.NPM_PUBLISH}}
if: ${{ steps.release.outputs.release_created }}
- name: Build package
run: cd huetiful
if: ${{ steps.release.outputs.release_created }}
- name: Run NPM publish
run: |
npm run code:publish
npm run publish
env:
NPM_TOKEN:${{secrets.NPM_PUBLISH}}
if: ${{ steps.release.outputs.release_created }}

0 comments on commit 30628a5

Please sign in to comment.