PHP Classes

File: .github/workflows/npm-publish.yml

Recommend this page to a friend!
  Packages of Boss Ibrahim Mussa   Caelrik   .github/workflows/npm-publish.yml   Download  
File: .github/workflows/npm-publish.yml
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Caelrik
Build Web user interface from PHP components
Author: By
Last change:
Date: 8 days ago
Size: 2,911 bytes
 

 

Contents

Class file image Download
name: Publish to npm # Publishes a released version to npm again: Actions > Publish to npm > Run workflow, # with the version (e.g. 0.7.0). For a release whose npm step failed (an expired token, # or one that asks for a one-time password): the Release workflow stops when the tag # exists, so it cannot be run again. # # The tag's commit holds the built bundle and package.json at the version: it is # published as it is, nothing is built. NPM_TOKEN must be an npm granular access token # with read and write access to the @caelrik scope and "Bypass two-factor authentication". on: workflow_dispatch: inputs: version: description: 'Released version, without the "v" (e.g. 0.7.0)' required: true permissions: contents: read id-token: write # npm provenance concurrency: group: release cancel-in-progress: false jobs: publish: runs-on: ubuntu-latest env: VERSION: ${{ inputs.version }} steps: - name: Check the version run: | if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then echo "::error::Invalid version \"$VERSION\": use 1.2.3 or 1.2.3-beta.1" exit 1 fi - uses: actions/checkout@v7 with: ref: refs/tags/v${{ inputs.version }} - uses: actions/setup-node@v7 with: node-version: '24' registry-url: 'https://registry.npmjs.org' - name: Check the package run: | name=$(node -p "require('./package.json').name") version=$(node -p "require('./package.json').version") if [[ "$version" != "$VERSION" ]]; then echo "::error::package.json at v$VERSION says $version" exit 1 fi if [[ ! -f public/caelrik.js ]]; then echo "::error::v$VERSION has no built bundle (public/caelrik.js)" exit 1 fi if npm view "$name@$VERSION" version > /dev/null 2>&1; then echo "::error::$name@$VERSION is already on npm" exit 1 fi - name: Publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | if [[ -z "$NODE_AUTH_TOKEN" ]]; then echo "::error::Add an NPM_TOKEN secret first." exit 1 fi # Pre-releases go to the "next" tag, so they never become "latest"; so does a # version older than the one npm has as "latest" (0.7.0 published after 0.7.1). latest=$(npm view "$(node -p "require('./package.json').name")" dist-tags.latest 2> /dev/null || true) tag=latest if [[ "$VERSION" == *-* ]]; then tag=next elif [[ -n "$latest" && "$(printf '%s\n%s\n' "$latest" "$VERSION" | sort -V | tail -1)" != "$VERSION" ]]; then tag=previous fi npm publish --provenance --access public --tag "$tag"