Skip to content

Commit 8c9af43

Browse files
authored
Merge pull request #4 from RightCapitalHQ/feature/migrate-to-nx
feat: migrate from beachball to nx release workflow
2 parents 2697de3 + 626231d commit 8c9af43

17 files changed

Lines changed: 781 additions & 356 deletions

.github/workflows/ci.yml

Lines changed: 66 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ jobs:
99
install:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v4
12+
- uses: actions/checkout@v6
1313
- uses: pnpm/action-setup@v4
14-
- uses: actions/setup-node@v4
14+
- uses: actions/setup-node@v6
1515
with:
1616
node-version-file: .node-version
1717
cache: pnpm
@@ -21,9 +21,9 @@ jobs:
2121
needs: install
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v4
24+
- uses: actions/checkout@v6
2525
- uses: pnpm/action-setup@v4
26-
- uses: actions/setup-node@v4
26+
- uses: actions/setup-node@v6
2727
with:
2828
node-version-file: .node-version
2929
cache: pnpm
@@ -36,40 +36,77 @@ jobs:
3636
needs: install
3737
runs-on: ubuntu-latest
3838
steps:
39-
- uses: actions/checkout@v4
39+
- uses: actions/checkout@v6
4040
- uses: docker://rhysd/actionlint:1.6.26
4141
with:
4242
args: -color
4343

44-
publish:
45-
if: ${{ always() && !failure() && !cancelled() }}
46-
needs: [test, check-workflow-files]
44+
check-version-plan:
45+
needs: install
46+
if: github.base_ref == github.event.repository.default_branch && github.head_ref != 'release' && !startsWith(github.head_ref, 'renovate/')
4747
runs-on: ubuntu-latest
48-
permissions:
49-
id-token: write
50-
contents: read
5148
steps:
52-
- uses: actions/checkout@v4
53-
- uses: pnpm/action-setup@v4
54-
- uses: actions/setup-node@v4
49+
- name: Checkout
50+
uses: actions/checkout@v6
51+
with:
52+
fetch-depth: 0
53+
54+
- name: Prepare pnpm
55+
uses: pnpm/action-setup@v4
56+
57+
- name: Prepare Node.js
58+
uses: actions/setup-node@v6
5559
with:
5660
node-version-file: .node-version
5761
cache: pnpm
58-
- run: pnpm install
59-
- run: pnpm run build
6062

61-
- name: Publish (development)
62-
if: github.event.pull_request.head.repo.full_name == 'RightCapitalHQ/verdaccio-package-diff' && github.base_ref == github.event.repository.default_branch
63-
env:
64-
HEAD_REF: ${{ github.head_ref }}
65-
run: |
66-
preid="${HEAD_REF//\//-}".${{ github.run_number }}.${{ github.run_attempt }}
67-
pnpm exec npm --no-git-tag-version version prerelease --preid="${preid}"
68-
pnpm publish --no-git-checks --access public --tag development
63+
- name: Install dependencies
64+
run: pnpm install
6965

70-
- name: Publish (main)
71-
if: github.repository == 'RightCapitalHQ/verdaccio-package-diff' && github.event_name == 'push' && github.ref_name == github.event.repository.default_branch
66+
- name: Set SHAs for Nx
67+
uses: nrwl/nx-set-shas@v4
68+
69+
- name: Check version plan
70+
run: pnpm exec nx release plan:check
71+
72+
check-renovate-version-plan:
73+
needs: install
74+
if: startsWith(github.event.pull_request.head.ref, 'renovate/') && github.base_ref == github.event.repository.default_branch
75+
uses: RightCapitalHQ/actions/.github/workflows/nx-release-auto-plan.yml@nx-release-auto-plan/v0.4.2
76+
secrets: inherit
77+
78+
prerelease:
79+
if: >-
80+
!failure() && !cancelled()
81+
&& github.event_name == 'pull_request'
82+
&& github.event.pull_request.head.repo.full_name == 'RightCapitalHQ/verdaccio-package-diff'
83+
&& github.base_ref == github.event.repository.default_branch
84+
&& github.head_ref != 'release'
85+
needs:
86+
[
87+
test,
88+
check-version-plan,
89+
check-renovate-version-plan,
90+
check-workflow-files,
91+
]
92+
runs-on: ubuntu-latest
93+
steps:
94+
- uses: actions/create-github-app-token@v3
95+
id: app-token
96+
with:
97+
app-id: ${{ secrets.RC_BOT_APP_ID }}
98+
private-key: ${{ secrets.RC_BOT_PRIVATE_KEY }}
99+
permission-actions: write
100+
- name: Trigger prerelease workflow
101+
env:
102+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
103+
BRANCH_NAME: ${{ github.head_ref }}
104+
RUN_NUMBER: ${{ github.run_number }}
105+
RUN_ATTEMPT: ${{ github.run_attempt }}
72106
run: |
73-
git config --local user.email "npm-publisher@rightcapital.com"
74-
git config --local user.name "GitHub Actions[bot]"
75-
pnpm beachball publish --access public --yes -m 'chore(release): applying package updates'
107+
gh workflow run release.yml \
108+
--repo "$GITHUB_REPOSITORY" \
109+
-f prerelease=true \
110+
-f "branch_name=${BRANCH_NAME}" \
111+
-f "run_number=${RUN_NUMBER}" \
112+
-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
@@ -5,3 +5,8 @@ npm-debug.log*
55
.pnpm-debug.log*
66
node_modules/
77
dist/
8+
9+
# nx
10+
/.nx/cache
11+
/.nx/workspace-data
12+
!/.nx/version-plans/

.husky/commit-msg

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
4-
npx --no -- commitlint --edit "$1"
1+
pnpm commitlint --edit --config=commitlint.config.js
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@rightcapital/verdaccio-package-diff": patch
3+
---
4+
5+
Migrate from beachball to Nx Release workflow.

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
pnpm-lock.yaml
22
dist/
3+
CHANGELOG.md
4+
.nx/version-plans/

CHANGELOG.json

Lines changed: 0 additions & 125 deletions
This file was deleted.

0 commit comments

Comments
 (0)