Skip to content

Commit 39c74ed

Browse files
authored
Merge pull request #561 from ForgeRock/changeset-release/master
Release PR
2 parents f181778 + 8b701bf commit 39c74ed

File tree

41 files changed

+12004
-7960
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+12004
-7960
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Setup publish
2+
description: Setup steps for publishing packages
3+
4+
inputs:
5+
CODECOV_TOKEN:
6+
description: 'Codecov token for uploading coverage reports'
7+
required: true
8+
9+
runs:
10+
using: 'composite'
11+
steps:
12+
- name: Install pnpm
13+
uses: pnpm/action-setup@v4
14+
with:
15+
run_install: false # don't install any packages yet
16+
17+
- name: Install Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version-file: '.node-version'
21+
cache: 'pnpm' # package manager for caching
22+
registry-url: 'https://registry.npmjs.org'
23+
24+
# Update npm to latest for provenance
25+
- name: Update npm
26+
run: npm install -g npm@latest
27+
shell: bash
28+
29+
- name: Install dependencies from lockfile
30+
run: pnpm install --frozen-lockfile
31+
shell: bash
32+
33+
# Allocate nx tasks across multiple machines/agents in the cloud
34+
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
35+
# https://nx.dev/docs/features/ci-features/distribute-task-execution
36+
- name: Enable distribution of nx tasks to cloud agents
37+
run: pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci" --with-env-vars="CODECOV_TOKEN"
38+
shell: bash
39+
env:
40+
CODECOV_TOKEN: ${{ inputs.CODECOV_TOKEN }}
41+
42+
# https://github.com/microsoft/playwright/issues/7249#issuecomment-1256878540
43+
- name: Cache Playwright browsers
44+
uses: actions/cache@v4
45+
with:
46+
path: ~/.cache/ms-playwright
47+
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
48+
restore-keys: |
49+
${{ runner.os }}-playwright-
50+
51+
- name: Install Playwright browsers
52+
run: pnpm exec playwright install
53+
shell: bash
54+
55+
- name: Derive SHAs for `nx affected`
56+
uses: nrwl/nx-set-shas@v4
57+
with:
58+
main-branch-name: master
59+
60+
- name: Run build, lint, test, and e2e for projects changed
61+
run: pnpm exec nx affected -t build lint test e2e-ci --agents
62+
shell: bash
63+
64+
- name: Save Playwright test results
65+
uses: actions/upload-artifact@v4
66+
if: ${{ !cancelled() }}
67+
with:
68+
name: playwright-report
69+
path: |
70+
./**/.playwright/**
71+
./dist/.playwright/**
72+
./dist/**
73+
retention-days: 30
74+
75+
- name: Ensure builds for all packages before publishing
76+
run: pnpm exec nx run-many -t build --no-agents # --no-agents to run in CI without distributing to agents
77+
shell: bash

.github/workflows/ci-fork.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: ForgeRock Fork Pull Request CI
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
actions: read
9+
10+
concurrency:
11+
group: pr-${{ github.event.pull_request.number }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
pr:
16+
# Only run for forks
17+
if: ${{ github.event.pull_request.head.repo.full_name != github.repository }}
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 20
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
# head commit is fine; the default merge ref also works on pull_request
25+
ref: ${{ github.event.pull_request.head.sha }}
26+
fetch-depth: 0
27+
28+
- uses: pnpm/action-setup@v4
29+
with:
30+
run_install: false
31+
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version-file: '.node-version'
35+
cache: 'pnpm'
36+
cache-dependency-path: '**/pnpm-lock.yaml'
37+
38+
- run: pnpm install --frozen-lockfile
39+
40+
# Restore-only cache to avoid save attempts/noise on forks
41+
- name: Restore Playwright browsers cache
42+
uses: actions/cache/restore@v4
43+
with:
44+
path: ~/.cache/ms-playwright
45+
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
46+
restore-keys: |
47+
${{ runner.os }}-playwright-
48+
49+
- run: pnpm exec playwright install --with-deps
50+
51+
- uses: nrwl/nx-set-shas@v4
52+
53+
# Needed so nx affected can diff against main
54+
- run: git branch --track main origin/main || true
55+
56+
- run: pnpm nx format:check
57+
- run: pnpm nx affected -t build typecheck lint test e2e-ci

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
env:
55
NX_CLOUD_ENCRYPTION_KEY: ${{ secrets.NX_CLOUD_ENCRYPTION_KEY }}
66
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
7-
NX_CLOUD_DISTRIBUTED_EXECUTION: true
87
jobs:
98
pr:
9+
if: ${{github.event.pull_request.head.repo.full_name == github.repository}}
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
@@ -25,7 +25,7 @@ jobs:
2525

2626
# This line enables distribution
2727
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
28-
- run: pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci" --verbose
28+
- run: pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci"
2929

3030
- run: pnpm exec playwright install
3131

@@ -34,7 +34,7 @@ jobs:
3434
- run: git branch --track develop origin/develop
3535

3636
- run: pnpm exec nx-cloud record -- nx format:check --verbose
37-
- run: pnpm exec nx affected -t build lint test docs e2e-ci --verbose
37+
- run: pnpm exec nx affected -t build lint test docs e2e-ci
3838

3939
- uses: codecov/codecov-action@v5
4040
with:

.github/workflows/publish.yml

Lines changed: 125 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,86 +4,88 @@ on:
44
branches:
55
- master
66
- develop
7+
workflow_dispatch:
8+
inputs:
9+
snapshot_tag:
10+
description: 'changesets snapshot tag (beta/canary)'
11+
required: false
12+
default: 'beta'
13+
type: string
14+
npm_tag:
15+
description: 'npm tag for publishing snapshot'
16+
required: false
17+
default: 'beta'
18+
type: string
19+
npm_access:
20+
description: 'access level for publishing snapshot to npm'
21+
required: false
22+
default: 'public'
23+
type: choice
24+
options:
25+
- public
26+
- restricted
727
env:
828
NX_CLOUD_ENCRYPTION_KEY: ${{ secrets.NX_CLOUD_ENCRYPTION_KEY }}
929
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
30+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
31+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
32+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
33+
SLACK_WEBHOOK_URL_BETA: ${{ secrets.SLACK_WEBHOOK_URL_BETA }}
1034
NX_CLOUD_DISTRIBUTED_EXECUTION: true
11-
PNPM_CACHE_FOLDER: .pnpm-store
12-
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
1335
HUSKY: 0
36+
CI: true
1437

1538
jobs:
39+
# On push to develop/master, create or update release PR or publish to npm
1640
publish-or-pr:
41+
if: github.event_name == 'push'
42+
name: Create/update release PR or publish to npm
1743
permissions:
1844
contents: write # to create release (changesets/action)
1945
issues: write # to post issue comments (changesets/action)
2046
pull-requests: write # to create pull request (changesets/action)
21-
id-token: write # give id token write for provenance
47+
id-token: write # OIDC for provenance if npm publish happens here
2248
runs-on: ubuntu-latest
2349
steps:
24-
- uses: actions/checkout@v4
25-
with:
26-
fetch-depth: 0
27-
- uses: pnpm/action-setup@v4
28-
with:
29-
run_install: false
30-
- uses: actions/setup-node@v4
31-
id: cache
32-
with:
33-
node-version: '20.10.0'
34-
cache: 'pnpm'
35-
36-
- run: pnpm install --frozen-lockfile
37-
38-
# This line enables distribution
39-
# The "--stop-agents-after" is optional, but allows idle agents to shut down once the "e2e-ci" targets have been requested
40-
- run: pnpm dlx nx-cloud start-ci-run --distribute-on="5 linux-medium-js" --stop-agents-after="e2e-ci" --verbose
41-
42-
- run: pnpm exec playwright install
50+
- name: Branch name
51+
run: |
52+
echo "Checking out branch: ${{ github.ref_name }}"
4353
44-
- uses: nrwl/nx-set-shas@v4
54+
- name: Checkout repository
55+
uses: actions/checkout@v4
4556
with:
46-
main-branch-name: master
47-
48-
- name: setup pnpm config
49-
run: pnpm config set store-dir $PNPM_CACHE_FOLDER
50-
51-
- run: pnpm exec nx affected -t build lint test e2e-ci --verbose
57+
fetch-depth: 0
5258

53-
- uses: actions/upload-artifact@v4
54-
if: ${{ !cancelled() }}
59+
- name: Setup publish
60+
uses: ./.github/actions/setup-publish
5561
with:
56-
name: playwright-report
57-
path: |
58-
./dist/.playwright/**
59-
./dist/**
60-
retention-days: 30
61-
62-
# make sure we have a build.
63-
- run: pnpm exec nx run-many -t build
64-
env:
65-
NX_CLOUD_DISTRIBUTED_EXECUTION: false
62+
CODECOV_TOKEN: ${{ env.CODECOV_TOKEN }}
6663

67-
- run: git status
68-
- name: publish
64+
# This action creates a release pull request with all of
65+
# the package versions and changelogs updated. When there
66+
# are new changesets on your configured baseBranch, the PR will
67+
# be updated. When you're ready, you can merge the release PR
68+
# and the action will publish to npm for you.
69+
# https://github.com/changesets/action
70+
- name: Create/update release PR or publish to npm
6971
uses: changesets/action@v1
7072
id: changesets
7173
with:
72-
publish: pnpm ci:release
73-
version: pnpm ci:version
74-
title: Release PR
75-
branch: master
76-
commit: 'chore: version-packages'
74+
publish: pnpm ci:release # command to tag and publish packages
75+
version: pnpm ci:version # command to update version, edit changelog, read and delete changesets
76+
branch: master # the branch to base the release PR against
77+
title: Release PR # title for the release PR
78+
commit: 'chore: version-packages' # the commit message to use
7779
setupGitUser: true
7880
env:
79-
# See https://github.com/changesets/action/issues/147
80-
HOME: ${{ github.workspace }}
81-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82-
NPM_CONFIG_PROVENANCE: 'true'
83-
NPM_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
84-
85-
- name: rebase develop with main on publish
86-
if: ${{ steps.changesets.outputs.published == 'true' }}
81+
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
82+
83+
- name: Publish previews to Stackblitz on PR
84+
if: steps.changesets.outputs.published == 'false'
85+
run: pnpm pkg-pr-new publish './packages/*' --packageManager=pnpm --comment=off
86+
87+
- name: Rebase develop with master on publish
88+
if: steps.changesets.outputs.published == 'true'
8789
run: |
8890
git restore .
8991
git checkout master
@@ -95,10 +97,73 @@ jobs:
9597
git rebase master
9698
git push -f
9799
env:
98-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99-
NPM_CONFIG_PROVENANCE: true
100+
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
101+
102+
- name: Format published packages for Slack
103+
if: steps.changesets.outputs.published == 'true'
104+
id: format-packages
105+
run: |
106+
PACKAGES=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[] | ":package: *\(.name)* `\(.version)`"')
107+
echo "formatted<<EOF" >> $GITHUB_OUTPUT
108+
echo "$PACKAGES" >> $GITHUB_OUTPUT
109+
echo "EOF" >> $GITHUB_OUTPUT
100110
101-
- uses: codecov/codecov-action@v5
111+
- name: Send GitHub Action data to a Slack workflow
112+
if: steps.changesets.outputs.published == 'true'
113+
uses: slackapi/slack-github-action@v2.1.1
114+
with:
115+
payload-delimiter: '_'
116+
webhook: ${{ env.SLACK_WEBHOOK_URL }}
117+
webhook-type: webhook-trigger
118+
payload: |
119+
publishedPackages: ${{ steps.format-packages.outputs.formatted }}
120+
121+
- name: Run code coverage
122+
uses: codecov/codecov-action@v5
102123
with:
103124
files: ./packages/**/coverage/*.xml
104-
token: ${{ secrets.CODECOV_TOKEN }}
125+
token: ${{ env.CODECOV_TOKEN }}
126+
127+
snapshot:
128+
# On manual trigger of GH action, publish a snapshot release to npm
129+
if: github.event_name == 'workflow_dispatch'
130+
name: Publish snapshot/beta release to npm
131+
permissions:
132+
contents: read
133+
id-token: write # OIDC for provenance when npm publish happens
134+
runs-on: ubuntu-latest
135+
steps:
136+
- name: Branch name
137+
run: |
138+
echo "Checking out branch: ${{ github.ref_name }}"
139+
140+
# Checkout the branch selected when triggering the workflow
141+
- name: Checkout repository
142+
uses: actions/checkout@v4
143+
with:
144+
fetch-depth: 0
145+
146+
- name: Setup publish
147+
uses: ./.github/actions/setup-publish
148+
with:
149+
CODECOV_TOKEN: ${{ env.CODECOV_TOKEN }}
150+
151+
- name: Version packages for snapshot
152+
run: pnpm changeset version --snapshot ${{ inputs.snapshot_tag }}
153+
env:
154+
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
155+
156+
- name: Publish packages snapshot with npm_tag
157+
id: npmpublish
158+
run: pnpm publish -r --tag ${{ inputs.npm_tag }} --no-git-checks --access ${{ inputs.npm_access }}
159+
160+
- name: Send GitHub Action data to a Slack workflow
161+
if: steps.npmpublish.outcome == 'success'
162+
uses: slackapi/slack-github-action@v2.1.1
163+
with:
164+
payload-delimiter: '_'
165+
webhook: ${{ env.SLACK_WEBHOOK_URL_BETA }}
166+
webhook-type: webhook-trigger
167+
payload: |
168+
npmTag: "${{ inputs.npm_tag }}"
169+
publishedPackages: ""

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20
1+
20

.npmrc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
link-workspace-packages=true
2-
strict-peer-dependencies=false
3-
save-workspace-protocol=rolling
4-
save-prefix=""
1+
registry=https://registry.npmjs.org/

0 commit comments

Comments
 (0)