tn-p1 #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "tn-p1" | |
on: | |
workflow_call: | |
workflow_dispatch: | |
inputs: | |
attestation_ver: | |
description: "Specific org.tokenscript:attestation version" | |
required: false | |
type: string | |
use_github_packages: | |
description: "Whether to use github packages for building" | |
required: false | |
default: false | |
type: boolean | |
jobs: | |
tn-p1: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
checks: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: "npm" | |
cache-dependency-path: package-lock.json | |
- name: install dependencies | |
run: | | |
npm ci | |
if [ "${USE_GITHUB_PACKAGES}" = "true" ]; then | |
echo "//npm.pkg.github.com/:_authToken=${GPR_KEY}" >> .npmrc | |
echo "@tokenscript:registry=https://npm.pkg.github.com" >> .npmrc | |
cat .npmrc | |
fi | |
if [ -n "${ATTESTATION_VER}" ]; then | |
npm i -E "@tokenscript/attestation@${ATTESTATION_VER}" | |
cat package.json | |
fi | |
# make SNAPSHOT-staging package to use @tokenscript/attestation:SNAPSHOT-staging | |
#if [ "${GITHUB_EVENT_NAME}" = "push" -a "${GITHUB_REF_NAME}" = "staging" ]; then | |
# echo "//npm.pkg.github.com/:_authToken=${GPR_KEY}" >> .npmrc | |
# echo "@tokenscript:registry=https://npm.pkg.github.com" >> .npmrc | |
# cat .npmrc | |
# npm i "@tokenscript/attestation@SNAPSHOT-staging" | |
#fi | |
rm -f .npmrc | |
env: | |
ATTESTATION_VER: ${{ inputs.attestation_ver }} | |
USE_GITHUB_PACKAGES: ${{ inputs.use_github_packages }} | |
GPR_KEY: ${{ secrets.GITHUB_TOKEN }} | |
- name: build | |
run: | | |
npm run build | |
npm run build-umd | |
- name: test | |
if: github.event_name != 'push' | |
uses: ArtiomTr/jest-coverage-report-action@v2 | |
with: | |
annotations: failed-tests | |
test-script: npm run test | |
- name: test | |
if: github.event_name == 'push' | |
run: npm run test | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: test-report | |
path: reports/ | |
- uses: actions/upload-artifact@v3 | |
if: github.event_name == 'push' | |
with: | |
name: token-negotiator-dist | |
path: token-negotiator-dist/ | |
- name: "Setup registry" | |
if: github.event_name == 'push' && contains('refs/heads/staging refs/heads/main', github.ref) | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16.x" | |
registry-url: "https://npm.pkg.github.com" | |
- name: "Publish NPM snapshot" | |
if: github.event_name == 'push' && contains('refs/heads/staging refs/heads/main', github.ref) | |
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" |