Skip to content

Commit

Permalink
Add simple script to tag and publish npm package releases.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtibbles committed Nov 14, 2024
1 parent 98180d1 commit df36fdf
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/npm_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Publish package to npm

on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
npm_package:
description: 'Package to publish to NPM'
required: true
type: choice
options:
- 'browserslist-config-kolibri'
- 'eslint-plugin-kolibri'
- 'kolibri'
- 'kolibri-app'
- 'kolibri-format'
- 'kolibri-logging'
- 'kolibri-module'
- 'kolibri-plugin-data'
- 'kolibri-viewer'

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Create tag
uses: actions/github-script@v7
with:
script: |
const packageJson = require(`./packages/${{ github.event.inputs.npm_package }}/package.json`)
const version = packageJson.version
const tagname = `npm/${{ github.event.inputs.npm_package }}/${version}`
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${tagname}`,
sha: context.sha
})
- run: |
cd packages/${{ github.event.inputs.npm_package }}
npm build | true
npm publish --provenance --access public
env:
# NPM_API_TOKEN is an organization-level secret
NODE_AUTH_TOKEN: ${{ secrets.NPM_API_TOKEN }}

0 comments on commit df36fdf

Please sign in to comment.