Skip to content

SFD-136 Set up workflow to publish npm package #4

SFD-136 Set up workflow to publish npm package

SFD-136 Set up workflow to publish npm package #4

Workflow file for this run

name: Publish new package
on:
workflow_dispatch:
pull_request: #TODO - For testing, remove before final merge
env:
PACKAGE_PREFIX: scottlogic-tech-carbon-estimator-
jobs:
package:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up environment
uses: ./.github/actions/set-up-environment
- name: Create package
run: |
npm run prepare
cp README.md package.json ./dist/tech-carbon-estimator/
cd dist/tech-carbon-estimator
npm pkg delete scripts private devDependencies files
npm pkg set main=main.js
npm pack
VERSION=$(npm pkg get version --workspaces=false | tr -d \")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: ${{env.PACKAGE_PREFIX}}${{env.VERSION}}
path: ./dist/tech-carbon-estimator/${{env.PACKAGE_PREFIX}}${{env.VERSION}}.tgz
overwrite: true #TODO - For testing, remove before final merge