Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 37 additions & 25 deletions .github/workflows/release.yml → .github/workflows/js.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
name: Checks and release
name: JavaScript Checks and Release

on:
push:
branches:
- main
paths:
- 'js/**'
- 'scripts/**'
- '.github/workflows/js.yml'
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'js/**'
- 'scripts/**'
- '.github/workflows/js.yml'
# Manual release support - consolidated here to work with npm trusted publishing
# npm only allows ONE workflow file as trusted publisher, so all publishing
# must go through this workflow (release.yml)
# must go through this workflow (js.yml)
workflow_dispatch:
inputs:
release_mode:
Expand All @@ -34,10 +42,14 @@ on:

concurrency: ${{ github.workflow }}-${{ github.ref }}

defaults:
run:
working-directory: js

jobs:
# Changeset check - only runs on PRs
changeset-check:
name: Check for Changesets
name: JS - Check for Changesets
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
Expand All @@ -62,11 +74,11 @@ jobs:
fi

# Run changeset validation script
node scripts/validate-changeset.mjs
node ../scripts/validate-changeset.mjs

# Linting and formatting - runs after changeset check on PRs, immediately on main
lint:
name: Lint and Format Check
name: JS - Lint and Format Check
runs-on: ubuntu-latest
needs: [changeset-check]
if: always() && (github.event_name == 'push' || needs.changeset-check.result == 'success')
Expand All @@ -92,7 +104,7 @@ jobs:

# Test matrix: Node.js on Ubuntu with unit tests and e2e tests
test:
name: Test (Node.js on ${{ matrix.os }})
name: JS - Test (Node.js on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: [changeset-check]
if: always() && (github.event_name == 'push' || needs.changeset-check.result == 'success')
Expand Down Expand Up @@ -128,7 +140,7 @@ jobs:

# Release - only runs on main after tests pass (for push events)
release:
name: Release
name: JS - Release
needs: [lint, test]
# Use always() to ensure this job runs even if changeset-check was skipped
# This is needed because lint/test jobs have a transitive dependency on changeset-check
Expand All @@ -154,7 +166,7 @@ jobs:
run: npm install

- name: Update npm for OIDC trusted publishing
run: node scripts/setup-npm.mjs
run: node ../scripts/setup-npm.mjs

- name: Check for changesets
id: check_changesets
Expand All @@ -167,31 +179,31 @@ jobs:
- name: Version packages and commit to main
if: steps.check_changesets.outputs.has_changesets == 'true'
id: version
run: node scripts/version-and-commit.mjs --mode changeset
run: node ../scripts/version-and-commit.mjs --mode changeset

- name: Publish to npm
# Run if version was committed OR if a previous attempt already committed (for re-runs)
if: steps.version.outputs.version_committed == 'true' || steps.version.outputs.already_released == 'true'
id: publish
run: node scripts/publish-to-npm.mjs --should-pull
run: node ../scripts/publish-to-npm.mjs --should-pull

- name: Create GitHub Release
if: steps.publish.outputs.published == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node scripts/create-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}"
run: node ../scripts/create-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}"

- name: Format GitHub release notes
if: steps.publish.outputs.published == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node scripts/format-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}" --commit-sha "${{ github.sha }}"
run: node ../scripts/format-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}" --commit-sha "${{ github.sha }}"

# Manual Instant Release - triggered via workflow_dispatch with instant mode
# This job is in release.yml because npm trusted publishing
# This job is in js.yml because npm trusted publishing
# only allows one workflow file to be registered as a trusted publisher
instant-release:
name: Instant Release
name: JS - Instant Release
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'instant'
runs-on: ubuntu-latest
# Permissions required for npm OIDC trusted publishing
Expand All @@ -214,33 +226,33 @@ jobs:
run: npm install

- name: Update npm for OIDC trusted publishing
run: node scripts/setup-npm.mjs
run: node ../scripts/setup-npm.mjs

- name: Version packages and commit to main
id: version
run: node scripts/version-and-commit.mjs --mode instant --bump-type "${{ github.event.inputs.bump_type }}" --description "${{ github.event.inputs.description }}"
run: node ../scripts/version-and-commit.mjs --mode instant --bump-type "${{ github.event.inputs.bump_type }}" --description "${{ github.event.inputs.description }}"

- name: Publish to npm
# Run if version was committed OR if a previous attempt already committed (for re-runs)
if: steps.version.outputs.version_committed == 'true' || steps.version.outputs.already_released == 'true'
id: publish
run: node scripts/publish-to-npm.mjs
run: node ../scripts/publish-to-npm.mjs

- name: Create GitHub Release
if: steps.publish.outputs.published == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node scripts/create-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}"
run: node ../scripts/create-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}"

- name: Format GitHub release notes
if: steps.publish.outputs.published == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node scripts/format-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}" --commit-sha "${{ github.sha }}"
run: node ../scripts/format-github-release.mjs --release-version "${{ steps.publish.outputs.published_version }}" --repository "${{ github.repository }}" --commit-sha "${{ github.sha }}"

# Manual Changeset PR - creates a pull request with the changeset for review
changeset-pr:
name: Create Changeset PR
name: JS - Create Changeset PR
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'changeset-pr'
runs-on: ubuntu-latest
permissions:
Expand All @@ -260,7 +272,7 @@ jobs:
run: npm install

- name: Create changeset file
run: node scripts/create-manual-changeset.mjs --bump-type "${{ github.event.inputs.bump_type }}" --description "${{ github.event.inputs.description }}"
run: node ../scripts/create-manual-changeset.mjs --bump-type "${{ github.event.inputs.bump_type }}" --description "${{ github.event.inputs.description }}"

- name: Format changeset with Prettier
run: |
Expand All @@ -273,12 +285,12 @@ jobs:
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: add changeset for manual ${{ github.event.inputs.bump_type }} release'
branch: changeset-manual-release-${{ github.run_id }}
commit-message: 'chore(js): add changeset for manual ${{ github.event.inputs.bump_type }} release'
branch: changeset-js-manual-release-${{ github.run_id }}
delete-branch: true
title: 'chore: manual ${{ github.event.inputs.bump_type }} release'
title: 'chore(js): manual ${{ github.event.inputs.bump_type }} release'
body: |
## Manual Release Request
## Manual Release Request (JavaScript)

This PR was created by a manual workflow trigger to prepare a **${{ github.event.inputs.bump_type }}** release.

Expand Down
Loading