-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (46 loc) · 1.54 KB
/
publish-package.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
publish:
runs-on: ubuntu-latest
needs: package
steps:
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Download package
uses: actions/download-artifact@v4
with:
name: ${{env.PACKAGE_PREFIX}}${{env.VERSION}}
- name: Publish to NPM registry
run: |
npm publish ${PACKAGE_PREFIX}${VERSION}.tgz --access public --dry-run