Skip to content

Commit 7cbdf49

Browse files
authored
Merge pull request #377 from RightCapitalHQ/feature/migrate-to-nx
feat: migrate from beachball to nx release workflow
2 parents 96c14f0 + 93e6cc8 commit 7cbdf49

18 files changed

Lines changed: 779 additions & 4122 deletions

.github/workflows/ci.yml

Lines changed: 58 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -10,59 +10,21 @@ jobs:
1010
install:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@v6
1414
- uses: pnpm/action-setup@v4
15-
- uses: actions/setup-node@v4.4.0
15+
- uses: actions/setup-node@v6
1616
with:
1717
node-version-file: .node-version
1818
cache: pnpm
1919
- run: pnpm install
2020

21-
check-renovate-changefile:
22-
if: startsWith(github.event.pull_request.head.ref, 'renovate/') && github.base_ref == github.event.repository.default_branch
23-
needs: install
24-
runs-on: ubuntu-latest
25-
steps:
26-
- uses: actions/checkout@v4
27-
with:
28-
ref: ${{ github.event.pull_request.head.ref }}
29-
token: ${{ secrets.RENOVATE_AUTO_BEACHBALL_CHANGEFILE_TOKEN }}
30-
31-
# Install dependencies (example using pnpm)
32-
- uses: pnpm/action-setup@v4
33-
- uses: actions/setup-node@v4
34-
with:
35-
node-version-file: .node-version
36-
cache: pnpm
37-
- run: pnpm install
38-
39-
- name: Check and generate changefile for Renovate
40-
# Pin to the last commit on main before this action was removed (replaced by renovate-auto-version-plan)
41-
uses: RightCapitalHQ/frontend-style-guide/.github/actions/renovate-auto-beachball-changefile@e7e6cdd89b0a5e56bb7b1b5280aae241d9e4e848
42-
43-
check-beachball-changefile:
44-
if: github.base_ref == github.event.repository.default_branch
45-
needs: install
46-
runs-on: ubuntu-latest
47-
steps:
48-
- uses: actions/checkout@v4
49-
- uses: pnpm/action-setup@v4
50-
- uses: actions/setup-node@v4.4.0
51-
with:
52-
node-version-file: .node-version
53-
cache: pnpm
54-
- run: pnpm install
55-
56-
- name: Check
57-
run: pnpm exec beachball check
58-
5921
test:
6022
needs: install
6123
runs-on: ubuntu-latest
6224
steps:
63-
- uses: actions/checkout@v4
25+
- uses: actions/checkout@v6
6426
- uses: pnpm/action-setup@v4
65-
- uses: actions/setup-node@v4.4.0
27+
- uses: actions/setup-node@v6
6628
with:
6729
node-version-file: .node-version
6830
cache: pnpm
@@ -77,40 +39,66 @@ jobs:
7739
- name: Test
7840
run: pnpm run test
7941

80-
build:
81-
if: ${{ always() && !failure() && !cancelled() }}
82-
needs: [test, check-beachball-changefile]
42+
check-version-plan:
43+
needs: install
44+
if: github.base_ref == github.event.repository.default_branch && github.head_ref != 'release' && !startsWith(github.head_ref, 'renovate/')
8345
runs-on: ubuntu-latest
84-
permissions:
85-
id-token: write
86-
contents: write
8746
steps:
88-
- uses: actions/checkout@v4
89-
- uses: pnpm/action-setup@v4
90-
- uses: actions/setup-node@v4.4.0
47+
- name: Checkout
48+
uses: actions/checkout@v6
49+
with:
50+
fetch-depth: 0
51+
52+
- name: Prepare pnpm
53+
uses: pnpm/action-setup@v4
54+
55+
- name: Prepare Node.js
56+
uses: actions/setup-node@v6
9157
with:
9258
node-version-file: .node-version
9359
cache: pnpm
94-
- run: pnpm install
9560

96-
- name: Build
97-
run: pnpm run build
61+
- name: Install dependencies
62+
run: pnpm install
9863

99-
- name: Publish (development)
100-
if: >-
101-
github.repository == 'RightCapitalHQ/phpdoc-parser' &&
102-
(github.base_ref == github.event.repository.default_branch ||
103-
(github.event_name == 'workflow_dispatch' && github.ref_name != github.event.repository.default_branch))
104-
env:
105-
HEAD_REF: ${{ github.head_ref || github.ref_name }}
106-
run: |
107-
preid="${HEAD_REF//\//-}".${{ github.run_number }}.${{ github.run_attempt }}
108-
npm --no-git-tag-version version prerelease --preid="${preid}"
109-
pnpm publish --no-git-checks --access public --tag development
64+
- name: Set SHAs for Nx
65+
uses: nrwl/nx-set-shas@v4
66+
67+
- name: Check version plan
68+
run: pnpm exec nx release plan:check
69+
70+
check-renovate-version-plan:
71+
needs: install
72+
if: startsWith(github.event.pull_request.head.ref, 'renovate/') && github.base_ref == github.event.repository.default_branch
73+
uses: RightCapitalHQ/actions/.github/workflows/nx-release-auto-plan.yml@nx-release-auto-plan/v0.4.2
74+
secrets: inherit
11075

111-
- name: Publish (main)
112-
if: github.repository == 'RightCapitalHQ/phpdoc-parser' && github.ref_name == github.event.repository.default_branch
76+
prerelease:
77+
if: >-
78+
!failure() && !cancelled()
79+
&& github.event_name == 'pull_request'
80+
&& github.event.pull_request.head.repo.full_name == 'RightCapitalHQ/phpdoc-parser'
81+
&& github.base_ref == github.event.repository.default_branch
82+
&& github.head_ref != 'release'
83+
needs: [test, check-version-plan, check-renovate-version-plan]
84+
runs-on: ubuntu-latest
85+
steps:
86+
- uses: actions/create-github-app-token@v3
87+
id: app-token
88+
with:
89+
app-id: ${{ secrets.RC_BOT_APP_ID }}
90+
private-key: ${{ secrets.RC_BOT_PRIVATE_KEY }}
91+
permission-actions: write
92+
- name: Trigger prerelease workflow
93+
env:
94+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
95+
BRANCH_NAME: ${{ github.head_ref }}
96+
RUN_NUMBER: ${{ github.run_number }}
97+
RUN_ATTEMPT: ${{ github.run_attempt }}
11398
run: |
114-
git config --local user.email "npm-publisher@rightcapital.com"
115-
git config --local user.name "GitHub Actions[bot]"
116-
pnpm beachball publish --access public --yes -m 'chore(release): applying package updates'
99+
gh workflow run release.yml \
100+
--repo "$GITHUB_REPOSITORY" \
101+
-f prerelease=true \
102+
-f "branch_name=${BRANCH_NAME}" \
103+
-f "run_number=${RUN_NUMBER}" \
104+
-f "run_attempt=${RUN_ATTEMPT}"

.github/workflows/release-pr.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Release PR
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
create-release-pr:
10+
uses: RightCapitalHQ/actions/.github/workflows/nx-release-pr.yml@nx-release-pr/v0.4.2
11+
with:
12+
release-branch: release
13+
base: main
14+
pr-title: 'chore(release): release packages'
15+
secrets: inherit

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
workflow_dispatch:
9+
inputs:
10+
prerelease:
11+
required: true
12+
type: boolean
13+
branch_name:
14+
required: true
15+
type: string
16+
run_number:
17+
required: true
18+
type: string
19+
run_attempt:
20+
required: true
21+
type: string
22+
23+
jobs:
24+
release:
25+
if: >-
26+
github.event_name == 'pull_request'
27+
&& github.event.pull_request.merged == true
28+
&& github.event.pull_request.head.ref == 'release'
29+
uses: RightCapitalHQ/actions/.github/workflows/nx-release.yml@nx-release/v0.4.2
30+
with:
31+
publish: true
32+
secrets: inherit
33+
34+
prerelease:
35+
if: inputs.prerelease
36+
runs-on: ubuntu-latest
37+
permissions:
38+
id-token: write
39+
contents: read
40+
steps:
41+
- uses: actions/checkout@v6
42+
with:
43+
ref: ${{ inputs.branch_name }}
44+
persist-credentials: false
45+
- uses: pnpm/action-setup@v4
46+
- uses: actions/setup-node@v6
47+
with:
48+
node-version-file: .node-version
49+
cache: pnpm
50+
- run: pnpm install
51+
52+
- name: Publish prerelease (development)
53+
env:
54+
BRANCH_NAME: ${{ inputs.branch_name }}
55+
RUN_NUMBER: ${{ inputs.run_number }}
56+
RUN_ATTEMPT: ${{ inputs.run_attempt }}
57+
NPM_CONFIG_PROVENANCE: true
58+
run: |
59+
preid="${BRANCH_NAME//\//-}".${RUN_NUMBER}.${RUN_ATTEMPT}
60+
npm --no-git-tag-version version prerelease --preid="${preid}"
61+
pnpm publish --no-git-checks --access public --tag development

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,8 @@ dist/
6363

6464
### JetBrains development tool ###
6565
/.idea
66+
67+
# nx
68+
/.nx/cache
69+
/.nx/workspace-data
70+
!/.nx/version-plans/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rightcapital/phpdoc-parser": patch
3+
---
4+
5+
Migrate from beachball to Nx Release workflow.

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# We need to ignore this cause this is auto-generated file
22
pnpm-lock.yaml
33
CHANGELOG.md
4-
CHANGELOG.json
4+
.nx/version-plans/

0 commit comments

Comments
 (0)