2021-11-11 06:56:21 +07:00
|
|
|
name: Publish Package
|
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types: [created]
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
skip:
|
|
|
|
description: Skip release to repository
|
|
|
|
required: false
|
|
|
|
tag:
|
|
|
|
description: Tag name
|
|
|
|
required: true
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
steps:
|
|
|
|
- name: Checkout release
|
|
|
|
if: github.event_name != 'workflow_dispatch'
|
2023-09-09 17:53:40 +07:00
|
|
|
uses: actions/checkout@v4
|
2021-11-11 06:56:21 +07:00
|
|
|
|
|
|
|
- name: Checkout tag
|
2023-09-09 17:53:40 +07:00
|
|
|
uses: actions/checkout@v4
|
2021-11-11 06:56:21 +07:00
|
|
|
if: github.event_name == 'workflow_dispatch'
|
|
|
|
with:
|
|
|
|
ref: ${{ github.event.inputs.tag }}
|
|
|
|
|
|
|
|
- name: Setup Node.js
|
2023-11-06 18:00:34 +07:00
|
|
|
uses: actions/setup-node@v4
|
2021-11-11 06:56:21 +07:00
|
|
|
with:
|
2024-11-04 10:25:26 +07:00
|
|
|
node-version: '20.x'
|
2021-11-11 06:56:21 +07:00
|
|
|
registry-url: https://registry.npmjs.org
|
|
|
|
|
2021-12-17 20:04:16 +07:00
|
|
|
- name: Install dependencies and add lib
|
|
|
|
run: |
|
|
|
|
npm install
|
|
|
|
npm run build
|
|
|
|
sed -i -e '/lib\//d' .gitignore
|
2021-11-11 06:56:21 +07:00
|
|
|
|
|
|
|
- name: Publish to NPM
|
|
|
|
if: "!contains(github.event.inputs.skip, 'skip-npm')"
|
|
|
|
run: npm publish --access public
|
|
|
|
env:
|
|
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
|
|
|
|
- name: Change to GitHub Packages registry
|
2023-11-06 18:00:34 +07:00
|
|
|
uses: actions/setup-node@v4
|
2021-11-11 06:56:21 +07:00
|
|
|
with:
|
|
|
|
registry-url: https://npm.pkg.github.com
|
|
|
|
scope: '@shivammathur'
|
|
|
|
|
|
|
|
- name: Patch package.json
|
|
|
|
run: |
|
|
|
|
sed -i 's#"name": "#"name": "@shivammathur/#' package.json
|
|
|
|
|
|
|
|
- name: Publish to GitHub Packages
|
|
|
|
if: "!contains(github.event.inputs.skip, 'skip-github-packages')"
|
|
|
|
run: npm publish
|
|
|
|
env:
|
|
|
|
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|