Skip to content

Publish Package to npmjs #27

Publish Package to npmjs

Publish Package to npmjs #27

Workflow file for this run

name: Publish Package to npmjs
on:
#push:
# branches: [ master, main ]
release:
types: [published]
jobs:
build:
permissions:
contents: write
packages: write
repository-projects: write
actions: write
deployments: write
checks: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
#
- name: Set output
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Check output
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
run: |
echo $RELEASE_VERSION
echo ${{ steps.vars.outputs.tag }}
#
- run: npm i
- run: npm run prepare
- run: npm run build
#
- name: Zip files for release
run: zip -r compress-nodejs-${RELEASE_VERSION}.zip dist/
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./compress-nodejs-${RELEASE_VERSION}.zip # Adjust according to your build output directory
asset_name: compress-nodejs-${RELEASE_VERSION}.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}