Skip to content

Commit

Permalink
build: move npm publish to semantic release (#27143)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice authored Feb 8, 2024
1 parent d424c7f commit 2d1e77d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 68 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
sparse-checkout: ${{ env.SPARSE_CHECKOUT }}
filter: blob:none # we don't need all blobs

- name: Calculate matrix for `node_modules` prefetch
uses: ./.github/actions/calculate-prefetch-matrix
Expand Down Expand Up @@ -548,11 +549,14 @@ jobs:
contents: write
issues: write
pull-requests: write
id-token: write

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

- name: Setup Node.js
uses: ./.github/actions/setup-node
Expand All @@ -570,11 +574,13 @@ jobs:
echo "DRY_RUN=false" >> "$GITHUB_ENV"
fi
# TODO: move to semantic-release prepare
- name: Build
run: pnpm build

- name: semantic-release
run: |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> ./.npmrc
pnpm semantic-release --dry-run ${{env.DRY_RUN}}
git checkout -- .npmrc
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
63 changes: 1 addition & 62 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ on:
required: false

env:
NODE_VERSION: 18
GIT_SHA: ${{ github.event.client_payload.sha }}
NPM_VERSION: ${{ github.event.client_payload.version }}
NPM_TAG: ${{ github.event.client_payload.tag }}
RENOVATE_VERSION: ${{ github.event.client_payload.version }}
BUILDKIT_PROGRESS: plain
BUILDX_NO_DEFAULT_LOAD: 1
Expand All @@ -46,68 +43,10 @@ jobs:
with:
branch: mutex-rel

release-npm:
runs-on: ubuntu-latest
needs:
- mutex

steps:
- name: Prepare env
run: |
if [[ "${{github.event_name}}" == "workflow_dispatch" ]]; then
echo "GIT_SHA=${{ github.event.inputs.sha }}" >> "$GITHUB_ENV"
echo "NPM_VERSION=${{ github.event.inputs.version }}" >> "$GITHUB_ENV"
echo "NPM_TAG=${{ github.event.inputs.tag }}" >> "$GITHUB_ENV"
fi
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ env.GIT_SHA }}
show-progress: false

- name: Enable corepack
shell: bash
run: corepack enable

- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm

- name: Init platform
run: |
git config --global core.autocrlf false
git config --global core.symlinks true
git config --global user.email '[email protected]'
git config --global user.name 'Renovate Bot'
- name: Installing dependencies
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
with:
timeout_minutes: 10
max_attempts: 3
command: pnpm install --frozen-lockfile

- name: Build ${{ env.NPM_VERSION }}
run: pnpm build

- name: Prepare ${{ env.NPM_VERSION }}
run: |
npm --no-git-tag-version version ${{ env.NPM_VERSION }}
- name: Publish ${{ env.NPM_VERSION }}
run: |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> ./.npmrc
npm publish --tag ${{ env.NPM_TAG }}
git checkout -- .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

release-docker:
runs-on: ubuntu-latest
needs:
- release-npm
- mutex

permissions:
contents: read
Expand Down
2 changes: 0 additions & 2 deletions .prettierrc

This file was deleted.

4 changes: 4 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
5 changes: 3 additions & 2 deletions .releaserc → .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
]
}
],
"@semantic-release/npm",
[
"@semantic-release/exec",
{
"prepareCmd": "run-s \"release:prepare -- {@}\" -- --release=${nextRelease.version} --sha=${nextRelease.gitHead} --tag=${nextRelease.channel}",
"publishCmd": "run-s \"release:publish -- {@}\" -- --release=${nextRelease.version} --sha=${nextRelease.gitHead} --tag=${nextRelease.channel}"
"prepareCmd": "pnpm release:prepare --release=${nextRelease.version} --sha=${nextRelease.gitHead} --tag=${nextRelease.channel}",
"publishCmd": "pnpm release:publish --release=${nextRelease.version} --sha=${nextRelease.gitHead} --tag=${nextRelease.channel}"
}
]
],
Expand Down

0 comments on commit 2d1e77d

Please sign in to comment.