mirror of
https://github.com/shivammathur/setup-php.git
synced 2026-09-22 02:29:42 +07:00
78 lines
2.5 KiB
YAML
78 lines
2.5 KiB
YAML
name: Publish Package
|
|
on:
|
|
release:
|
|
types: [created]
|
|
workflow_dispatch:
|
|
inputs:
|
|
skip:
|
|
description: Skip release to repository
|
|
required: false
|
|
tag:
|
|
description: Tag name
|
|
required: true
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
permissions:
|
|
contents: read
|
|
jobs:
|
|
build:
|
|
name: Build and Publish
|
|
permissions:
|
|
contents: read # for actions/checkout
|
|
packages: write # For publishing to GitHub Packages
|
|
id-token: write # For authentication with npm registry
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout release
|
|
if: github.event_name != 'workflow_dispatch'
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Checkout tag
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
if: github.event_name == 'workflow_dispatch'
|
|
with:
|
|
ref: ${{ github.event.inputs.tag }}
|
|
persist-credentials: false
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
|
|
with:
|
|
node-version: '24.x'
|
|
registry-url: https://registry.npmjs.org
|
|
package-manager-cache: false
|
|
|
|
- name: Install dependencies and add lib
|
|
run: |
|
|
npm install
|
|
npm run build
|
|
sed -i -e '/lib\//d' .gitignore
|
|
|
|
- name: Select npm distribution tag
|
|
id: publish-tag
|
|
run: |
|
|
jq -r '.version | if test("alpha|beta|rc"; "i") then "tag=next" else "tag=latest" end' package.json >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Publish to NPM
|
|
if: "!contains(github.event.inputs.skip, 'skip-npm')"
|
|
run: npm publish --access public --tag "${{ steps.publish-tag.outputs.tag }}"
|
|
|
|
- name: Change to GitHub Packages registry
|
|
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
|
|
with:
|
|
registry-url: https://npm.pkg.github.com
|
|
package-manager-cache: false
|
|
scope: '@shivammathur'
|
|
|
|
- name: Patch package.json
|
|
run: |
|
|
sed -i 's#"name": "#"name": "@shivammathur/#' package.json
|
|
|
|
- name: Publish to GitHub Packages
|
|
if: "!contains(github.event.inputs.skip, 'skip-github-packages')"
|
|
run: npm publish --tag "${{ steps.publish-tag.outputs.tag }}"
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|