Yet more improvements / fixes #1
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: release-please | ||
on: | ||
workflow_call: | ||
inputs: | ||
config-file: | ||
description: 'The path to the release-please config file' | ||
required: false | ||
default: '.github/release-please/config.json' | ||
type: string | ||
manifest-file: | ||
description: 'The path to the release-please manifest file' | ||
required: false | ||
default: '.github/release-please/manifest.json' | ||
type: string | ||
publish-to-github: | ||
description: 'Publish to GitHub Package Registry' | ||
required: false | ||
default: false | ||
type: boolean | ||
lockfile: | ||
description: 'Whether to expect a lockfile or not' | ||
required: false | ||
default: false | ||
type: boolean | ||
npm-tag: | ||
description: 'The distribution tag to publish to on npm' | ||
required: false | ||
default: 'latest' | ||
type: string | ||
app-id: | ||
description: 'The ID of a GitHub App that should be used to create the PR' | ||
required: false | ||
type: string | ||
permissions: | ||
contents: read | ||
jobs: | ||
release_please_bot_token: | ||
name: release-please bot | ||
if: inputs.app-id != null | ||
environment: pr-bot | ||
runs-on: ubuntu-latest | ||
outputs: | ||
releaseCreated: ${{ steps.release.outputs.release_created }} | ||
steps: | ||
# Generate bot token | ||
- uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: ${{ inputs.app-id }} | ||
private-key: ${{ secrets.APP_PEM }} | ||
- uses: googleapis/release-please-action@v4 | ||
id: release | ||
with: | ||
config-file: ${{ inputs.config-file }} | ||
manifest-file: ${{ inputs.manifest-file }} | ||
token: ${{ steps.app-token.outputs.token }} | ||
release_please_github_token: | ||
name: release-please github token | ||
if: inputs.app-id == null | ||
runs-on: ubuntu-latest | ||
outputs: | ||
releaseCreated: ${{ steps.release.outputs.release_created }} | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- uses: googleapis/release-please-action@v4 | ||
id: release | ||
with: | ||
config-file: ${{ inputs.config-file }} | ||
manifest-file: ${{ inputs.manifest-file }} | ||
release_please: | ||
name: release-please | ||
needs: [release_please_bot_token, release_please_github_token] | ||
if: success() || cancelled() | ||
runs-on: ubuntu-latest | ||
outputs: | ||
releaseCreated: ${{ needs.release_please_bot_token.outputs.releaseCreated || needs.release_please_github_token.outputs.releaseCreated }} | ||
npm_publish: | ||
name: Publish to npm | ||
runs-on: ubuntu-latest | ||
environment: npm | ||
needs: release_please | ||
if: needs.release_please.outputs.releaseCreated | ||
permissions: | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
show-progress: false | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm install -g npm | ||
- if: inputs.lockfile == false | ||
run: npm install | ||
- if: inputs.lockfile == true | ||
run: npm ci | ||
- run: npm publish --provenance --access public --tag=${{ inputs.npm-tag }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
gpr_publish: | ||
name: Publish to GitHub Package Registry | ||
runs-on: ubuntu-latest | ||
needs: release_please | ||
if: inputs.publish-to-github && needs.release_please.outputs.releaseCreated | ||
permissions: | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
show-progress: false | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
- if: inputs.lockfile == false | ||
run: npm install | ||
- if: inputs.lockfile == true | ||
run: npm ci | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
registry-url: 'https://npm.pkg.github.com' | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |