Skip to content

Commit

Permalink
add publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lenkan committed May 5, 2024
1 parent 7d6ae9f commit 2bf071b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish NPM

on:
workflow_dispatch:
inputs:
dry-run:
type: boolean
default: true
description: Dry run publish
push:
branches:
- 'main'

jobs:
publish:
name: Create npm package
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Set package name
if: ${{ vars.NPM_PACKAGE_NAME }}
run: |
cat package.json | jq -r '.name = "${{ vars.NPM_PACKAGE_NAME }}"' > package.json
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Set version from commit
run: |
npm version --no-git-tag-version $(cat package.json | jq .version -r)-dev.$(git rev-parse --short HEAD)
- name: Publish dev package (Dry run)
if: ${{ inputs.dry-run == true }}
run: npm publish --tag dev --dry-run
- name: Publish dev package
if: ${{ inputs.dry-run == false }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --tag dev
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"types": "./dist/index.d.ts",
"type": "module",
"files": [
"dist",
"src"
"dist"
],
"scripts": {
"start": "npm run build:esm -- --watch",
Expand Down

0 comments on commit 2bf071b

Please sign in to comment.