-
Notifications
You must be signed in to change notification settings - Fork 11
60 lines (52 loc) · 1.85 KB
/
tn-snapshot.yml
File metadata and controls
60 lines (52 loc) · 1.85 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
name: "Manually publish snapshot package"
on:
workflow_dispatch:
jobs:
tn-snapshot:
name: "Publish snapshot package"
runs-on: ubuntu-latest
if: contains('refs/heads/staging refs/heads/main', github.ref)
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v4
with:
node-version: 16
cache: "npm"
cache-dependency-path: package-lock.json
- name: install dependencies
run: |
npm ci
# make SNAPSHOT-staging package to use @tokenscript/attestation:SNAPSHOT-staging
if [ "${GITHUB_REF_NAME}" = "staging" ]; then
echo "//npm.pkg.github.com/:_authToken=${GPR_KEY}" >> .npmrc
echo "@tokenscript:registry=https://npm.pkg.github.com" >> .npmrc
npm i "@tokenscript/attestation@SNAPSHOT-staging"
fi
env:
GPR_KEY: ${{ secrets.GITHUB_TOKEN }}
- name: build
run: |
npm run build
- name: "Setup registry"
uses: actions/setup-node@v4
with:
node-version: "16.x"
registry-url: "https://npm.pkg.github.com"
- name: "Publish NPM snapshot"
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SNAPSHOT_VERSION: ${{ github.ref == 'refs/heads/staging' && 'staging' || 'main' }}
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
SNAP_TAG="SNAPSHOT-$SNAPSHOT_VERSION"
./scripts/set_version.js "$CURRENT_VERSION-$SNAP_TAG.${GITHUB_SHA::6}"
npm publish --tag "$SNAP_TAG" --access restricted
- uses: actions/delete-package-versions@v4
with:
package-name: token-negotiator
package-type: npm
min-versions-to-keep: 4
delete-only-pre-release-versions: "true"