Skip to content

Merge pull request #27 from platacard/dependabot/npm_and_yarn/react-r… #34

Merge pull request #27 from platacard/dependabot/npm_and_yarn/react-r…

Merge pull request #27 from platacard/dependabot/npm_and_yarn/react-r… #34

Workflow file for this run

name: Publish Build
on:
workflow_dispatch:
push:
branches: [main]
permissions:
contents: read
# Serialize publish runs (do NOT cancel a publish mid-upload) so concurrent runs
# cannot race tag creation in scripts/create-tag.js.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
outputs:
needs_release: ${{ steps.release_check.outputs.needs_release }}
strategy:
matrix:
node-version: [22]
env:
CI: true
NODE_OPTIONS: --max-old-space-size=4096
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
# check-if-release.js diffs HEAD against its parent commit; without full
# history HEAD^ is missing on the default shallow checkout (e.g. on
# workflow_dispatch, where github.event.before is empty).
fetch-depth: 0
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --immutable
- name: Fetch previous commit for release check
if: github.event.before != '' && github.event.before != '0000000000000000000000000000000000000000'
run: git fetch origin '${{ github.event.before }}'
- name: Check if release
id: release_check
run: node scripts/check-if-release.js
env:
COMMIT_SHA_BEFORE: '${{ github.event.before }}'
# A separate release build that is only run for commits that are the result of merging the "Version Packages" PR
# We can't re-use the output from the above step, but we'll have a guaranteed node_modules cache and
# only run the build steps that are necessary for publishing
release:
needs: build
if: needs.build.outputs.needs_release == 'true'
permissions:
contents: write # create the git tag + GitHub release
id-token: write # npm provenance attestation (Sigstore via OIDC)
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22]
env:
CI: 'true'
NODE_OPTIONS: --max-old-space-size=4096
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
always-auth: true
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org
- run: yarn install --immutable
- name: build type declarations
run: yarn tsc
- name: build packages
run: yarn backstage-cli repo build
# Publishes current version of packages that are not already present in the registry.
- name: Run publish
# Yarn Berry reads the npm token from YARN_NPM_AUTH_TOKEN; passing it via
# env (not interpolated into the run body / persisted to ~/.yarnrc.yml)
# keeps it out of the rendered command line and process args.
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn workspaces foreach -W -v \
--no-private npm publish \
--access public \
--provenance \
--tolerate-republish
# Creates the next available tag with format "release-<year>-<month>-<day>[.<n>]"
- name: Create a release tag
id: create_tag
run: node scripts/create-tag.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Convert the newly created tag into a release with changelog information
- name: Create release on GitHub
run: node scripts/create-github-release.js ${{ steps.create_tag.outputs.tag_name }} 1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}