Skip to content

Commit 2d1e77d

Browse files
authored
build: move npm publish to semantic release (#27143)
1 parent d424c7f commit 2d1e77d

File tree

5 files changed

+16
-68
lines changed

5 files changed

+16
-68
lines changed

.github/workflows/build.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ jobs:
9696
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
9797
with:
9898
sparse-checkout: ${{ env.SPARSE_CHECKOUT }}
99+
filter: blob:none # we don't need all blobs
99100

100101
- name: Calculate matrix for `node_modules` prefetch
101102
uses: ./.github/actions/calculate-prefetch-matrix
@@ -548,11 +549,14 @@ jobs:
548549
contents: write
549550
issues: write
550551
pull-requests: write
552+
id-token: write
551553

552554
steps:
553555
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
554556
with:
555557
fetch-depth: 0 # zero stands for full checkout, which is required for semantic-release
558+
show-progress: false
559+
filter: blob:none # we don't need all blobs, only the full tree
556560

557561
- name: Setup Node.js
558562
uses: ./.github/actions/setup-node
@@ -570,11 +574,13 @@ jobs:
570574
echo "DRY_RUN=false" >> "$GITHUB_ENV"
571575
fi
572576
577+
# TODO: move to semantic-release prepare
578+
- name: Build
579+
run: pnpm build
580+
573581
- name: semantic-release
574582
run: |
575-
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> ./.npmrc
576583
pnpm semantic-release --dry-run ${{env.DRY_RUN}}
577-
git checkout -- .npmrc
578584
env:
579585
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
580586
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yml

+1-62
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ on:
1818
required: false
1919

2020
env:
21-
NODE_VERSION: 18
2221
GIT_SHA: ${{ github.event.client_payload.sha }}
23-
NPM_VERSION: ${{ github.event.client_payload.version }}
24-
NPM_TAG: ${{ github.event.client_payload.tag }}
2522
RENOVATE_VERSION: ${{ github.event.client_payload.version }}
2623
BUILDKIT_PROGRESS: plain
2724
BUILDX_NO_DEFAULT_LOAD: 1
@@ -46,68 +43,10 @@ jobs:
4643
with:
4744
branch: mutex-rel
4845

49-
release-npm:
50-
runs-on: ubuntu-latest
51-
needs:
52-
- mutex
53-
54-
steps:
55-
- name: Prepare env
56-
run: |
57-
if [[ "${{github.event_name}}" == "workflow_dispatch" ]]; then
58-
echo "GIT_SHA=${{ github.event.inputs.sha }}" >> "$GITHUB_ENV"
59-
echo "NPM_VERSION=${{ github.event.inputs.version }}" >> "$GITHUB_ENV"
60-
echo "NPM_TAG=${{ github.event.inputs.tag }}" >> "$GITHUB_ENV"
61-
fi
62-
63-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
64-
with:
65-
ref: ${{ env.GIT_SHA }}
66-
show-progress: false
67-
68-
- name: Enable corepack
69-
shell: bash
70-
run: corepack enable
71-
72-
- name: Set up Node.js ${{ env.NODE_VERSION }}
73-
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
74-
with:
75-
node-version: ${{ env.NODE_VERSION }}
76-
cache: pnpm
77-
78-
- name: Init platform
79-
run: |
80-
git config --global core.autocrlf false
81-
git config --global core.symlinks true
82-
git config --global user.email '[email protected]'
83-
git config --global user.name 'Renovate Bot'
84-
85-
- name: Installing dependencies
86-
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
87-
with:
88-
timeout_minutes: 10
89-
max_attempts: 3
90-
command: pnpm install --frozen-lockfile
91-
92-
- name: Build ${{ env.NPM_VERSION }}
93-
run: pnpm build
94-
95-
- name: Prepare ${{ env.NPM_VERSION }}
96-
run: |
97-
npm --no-git-tag-version version ${{ env.NPM_VERSION }}
98-
99-
- name: Publish ${{ env.NPM_VERSION }}
100-
run: |
101-
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> ./.npmrc
102-
npm publish --tag ${{ env.NPM_TAG }}
103-
git checkout -- .npmrc
104-
env:
105-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
106-
10746
release-docker:
10847
runs-on: ubuntu-latest
10948
needs:
110-
- release-npm
49+
- mutex
11150

11251
permissions:
11352
contents: read

.prettierrc

-2
This file was deleted.

.prettierrc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

.releaserc renamed to .releaserc.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
]
1515
}
1616
],
17+
"@semantic-release/npm",
1718
[
1819
"@semantic-release/exec",
1920
{
20-
"prepareCmd": "run-s \"release:prepare -- {@}\" -- --release=${nextRelease.version} --sha=${nextRelease.gitHead} --tag=${nextRelease.channel}",
21-
"publishCmd": "run-s \"release:publish -- {@}\" -- --release=${nextRelease.version} --sha=${nextRelease.gitHead} --tag=${nextRelease.channel}"
21+
"prepareCmd": "pnpm release:prepare --release=${nextRelease.version} --sha=${nextRelease.gitHead} --tag=${nextRelease.channel}",
22+
"publishCmd": "pnpm release:publish --release=${nextRelease.version} --sha=${nextRelease.gitHead} --tag=${nextRelease.channel}"
2223
}
2324
]
2425
],

0 commit comments

Comments
 (0)