Skip to content

2.1.2

2.1.2 #6

Workflow file for this run

# Publish
#
# Cross-publish package to GitHub Package Registry and NPM when a GitHub release is published or on
# workflow dispatch.
#
# References:
#
# - https://docs.github.com/actions/learn-github-actions/contexts
# - https://docs.github.com/actions/learn-github-actions/expressions
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#release
# - https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions
# - https://docs.github.com/webhooks-and-events/webhooks/webhook-events-and-payloads#release
# - https://docs.npmjs.com/trusted-publishers
# - https://github.com/actions/checkout
# - https://github.com/actions/setup-node
# - https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#yarn2-configuration
# - https://github.com/hmarr/debug-action
# - https://github.com/flex-development/gh-release-url-action
# - https://github.com/flex-development/ghr-url-action
# - https://github.com/flex-development/manver-action
# - https://github.com/flex-development/npm-url-action
---
name: publish
on:
release:
types:
- published
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref_name }}
jobs:
preflight:
permissions:
contents: read
runs-on: ubuntu-latest
outputs:
command: ${{ steps.command.outputs.result }}
version: ${{ steps.version.outputs.manifest }}
steps:
- id: debug
name: Print environment variables and event payload
uses: hmarr/[email protected]
- id: checkout
name: Checkout ${{ github.ref_name }}
uses: actions/[email protected]
with:
persist-credentials: false
ref: ${{ github.ref }}
- id: version
name: Get package version
uses: flex-development/[email protected]
- id: artifact
name: Get release artifact download url
uses: flex-development/[email protected]
with:
artifact: |
${{ format('@{0}-{1}-{2}.tgz', github.repository_owner, github.event.repository.name, steps.version.outputs.manifest) }}
version: ${{ github.ref_name }}
- id: dist
name: Get dist tag
uses: flex-development/[email protected]
with:
target: ${{ steps.version.outputs.manifest }}
- id: command
name: Get publish command
env:
ARTIFACT: ${{ steps.artifact.outputs.artifact }}
FLAGS: ${{ steps.dist.outputs.flag }}
run: echo "result=npm publish $FLAGS $ARTIFACT" >>$GITHUB_OUTPUT
gpr:
needs: preflight
permissions:
contents: read
id-token: write
packages: write
runs-on: ubuntu-latest
environment:
name: gpr
url: ${{ steps.environment.outputs.url }}
steps:
- id: environment
name: Get environment url
uses: flex-development/[email protected]
- id: checkout
name: Checkout ${{ github.ref_name }}
uses: actions/[email protected]
with:
persist-credentials: false
ref: ${{ github.ref }}
- id: npmrc
name: Setup .npmrc file
uses: actions/[email protected]
with:
node-version-file: .nvmrc
registry-url: https://npm.pkg.github.com
scope: ${{ github.repository_owner }}
- id: npmrc-print
name: Print contents of .npmrc file
run: cat $NPM_CONFIG_USERCONFIG
- id: publish
name: Publish package
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ${{ needs.preflight.outputs.command }}
npm:
needs: preflight
permissions:
contents: read
id-token: write
packages: write
runs-on: ubuntu-latest
environment:
name: npm
url: ${{ steps.environment.outputs.url }}
steps:
- id: environment
name: Get environment url
uses: flex-development/[email protected]
with:
scope: ${{ github.repository_owner }}
version: ${{ needs.preflight.outputs.version }}
- id: checkout
name: Checkout ${{ github.ref_name }}
uses: actions/[email protected]
with:
persist-credentials: false
ref: ${{ github.ref }}
- id: npmrc
name: Setup .npmrc file
uses: actions/[email protected]
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org
scope: ${{ github.repository_owner }}
- id: npmrc-print
name: Print contents of .npmrc file
run: cat $NPM_CONFIG_USERCONFIG
- id: publish
name: Publish package
run: ${{ needs.preflight.outputs.command }}