2021-04-06 17:37:17 +00:00
name : Publish NPM
2024-08-16 20:15:14 +00:00
run-name : Publish NPM - ${{ github.event.inputs.package }}
2021-04-06 17:37:17 +00:00
on :
workflow_dispatch :
inputs :
package :
required : true
2024-02-26 19:32:45 +00:00
description : 'core, artifact, cache, exec, github, glob, http-client, io, tool-cache, attest'
2022-05-03 15:10:13 +00:00
2021-04-06 17:37:17 +00:00
jobs :
test :
2024-11-01 15:59:55 +00:00
runs-on : macos-latest-large
2021-04-06 17:37:17 +00:00
steps :
- name : setup repo
2024-02-01 17:50:47 +00:00
uses : actions/checkout@v4
2021-04-06 17:37:17 +00:00
- name : verify package exists
run : ls packages/${{ github.event.inputs.package }}
2022-05-03 15:10:13 +00:00
2023-08-28 14:40:06 +00:00
- name : Set Node.js 20.x
2024-02-01 17:50:47 +00:00
uses : actions/setup-node@v4
2021-12-07 15:38:25 +00:00
with :
2023-08-28 14:40:06 +00:00
node-version : 20. x
2022-05-03 15:10:13 +00:00
2021-04-06 17:37:17 +00:00
- name : npm install
run : npm install
2022-05-03 15:10:13 +00:00
2021-04-06 17:37:17 +00:00
- name : bootstrap
run : npm run bootstrap
2022-05-03 15:10:13 +00:00
2021-04-06 17:37:17 +00:00
- name : build
run : npm run build
2022-05-03 15:10:13 +00:00
2021-04-06 17:37:17 +00:00
- name : test
run : npm run test
- name : pack
run : npm pack
working-directory : packages/${{ github.event.inputs.package }}
2022-05-03 15:10:13 +00:00
2021-04-06 17:37:17 +00:00
- name : upload artifact
2024-02-01 17:50:47 +00:00
uses : actions/upload-artifact@v4
2021-04-06 17:37:17 +00:00
with :
name : ${{ github.event.inputs.package }}
path : packages/${{ github.event.inputs.package }}/*.tgz
2022-05-03 15:10:13 +00:00
2021-04-06 17:37:17 +00:00
publish :
2024-11-01 15:59:55 +00:00
runs-on : macos-latest-large
2021-04-06 17:37:17 +00:00
needs : test
environment : npm-publish
2024-02-26 19:32:45 +00:00
permissions :
contents : read
id-token : write
2021-04-06 17:37:17 +00:00
steps :
2022-05-03 15:10:13 +00:00
2021-04-06 17:37:17 +00:00
- name : download artifact
2024-02-01 17:50:47 +00:00
uses : actions/download-artifact@v4
2021-04-06 17:37:17 +00:00
with :
name : ${{ github.event.inputs.package }}
2021-04-06 18:41:33 +00:00
- name : setup authentication
run : echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
2022-05-03 15:10:13 +00:00
env :
2021-04-06 17:37:17 +00:00
NPM_TOKEN : ${{ secrets.TOKEN }}
2021-04-06 18:41:33 +00:00
- name : publish
2024-02-26 18:42:33 +00:00
run : npm publish --provenance *.tgz
2021-04-06 18:41:33 +00:00
2021-04-06 17:37:17 +00:00
- name : notify slack on failure
if : failure()
run : |
curl -X POST -H 'Content-type : application/json' --data '{"text":":pb__failed: Failed to publish a new version of ${{ github.event.inputs.package }}"}' $SLACK_WEBHOOK
2022-05-03 15:10:13 +00:00
env :
2021-04-06 17:37:17 +00:00
SLACK_WEBHOOK : ${{ secrets.SLACK }}
2022-05-03 15:10:13 +00:00
2021-04-06 17:37:17 +00:00
- name : notify slack on success
if : success()
run : |
curl -X POST -H 'Content-type : application/json' --data '{"text":":dance: Successfully published a new version of ${{ github.event.inputs.package }}"}' $SLACK_WEBHOOK
2022-05-03 15:10:13 +00:00
env :
2021-04-06 17:37:17 +00:00
SLACK_WEBHOOK : ${{ secrets.SLACK }}
2022-05-03 15:10:13 +00:00