92c5235a00
- Upgrade lerna from v8 to v9 (adds OIDC trusted publishing support) - Remove registry-url, scope, and packages:write from release workflow - Remove NPM_CONFIG_PROVENANCE env (automatic with OIDC) - Update workspace typescript devDependency from ^4.8.4 to ^5.8.3 - Remove root typescript override (no longer needed)
101 lines
2.7 KiB
YAML
101 lines
2.7 KiB
YAML
name: Release and publish packages
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- lerna.json
|
|
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "Version to release"
|
|
required: true
|
|
|
|
jobs:
|
|
check-version-change:
|
|
outputs:
|
|
changed: ${{ steps.check-version.outputs.result }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Check if version has changed
|
|
id: check-version
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const version = '${{ inputs.version }}' || require('./lerna.json').version;
|
|
// Find a release for that version
|
|
const release = await github.rest.repos.getReleaseByTag({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
tag: `release-v${version}`,
|
|
}).catch(() => null);
|
|
|
|
// If the release exists, the version has not changed
|
|
if (release) {
|
|
console.log(`Version ${version} has an existing release`);
|
|
console.log(release.data.html_url);
|
|
core.summary.addLink(`Release v${version}`, release.data.html_url);
|
|
await core.summary.write();
|
|
return "false";
|
|
}
|
|
console.log(`Version ${version} does not have a release`);
|
|
return true;
|
|
|
|
release:
|
|
environment: publish
|
|
|
|
needs: check-version-change
|
|
if: ${{ needs.check-version-change.outputs.changed == 'true' }}
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
contents: write
|
|
id-token: write
|
|
|
|
env:
|
|
PKG_VERSION: "" # will be set in the workflow
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24.x
|
|
cache: "npm"
|
|
|
|
- name: Parse version from lerna.json
|
|
run: |
|
|
echo "PKG_VERSION=$(node -p -e "require('./lerna.json').version")" >> $GITHUB_ENV
|
|
|
|
- run: npm ci
|
|
|
|
- name: Create release
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const fs = require("fs");
|
|
|
|
const release = await github.rest.repos.createRelease({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
tag_name: "release-v${{ env.PKG_VERSION }}",
|
|
name: "v${{ env.PKG_VERSION }}",
|
|
draft: false,
|
|
prerelease: false
|
|
});
|
|
|
|
core.summary.addLink(`Release v${{ env.PKG_VERSION }}`, release.data.html_url);
|
|
await core.summary.write();
|
|
|
|
- name: Publish packages
|
|
run: |
|
|
npx lerna publish ${{ env.PKG_VERSION }} --yes --no-git-reset --no-git-tag-version |