renovate-release #4078
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release-npm | |
on: | |
repository_dispatch: | |
types: [renovate-release] | |
workflow_dispatch: | |
inputs: | |
sha: | |
description: 'Git sha to checkout' | |
required: true | |
version: | |
description: 'Version to release' | |
required: true | |
tag: | |
description: 'Npm dist-tag' | |
default: 'latest' | |
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 }} | |
permissions: | |
contents: read | |
id-token: write | |
jobs: | |
release-npm: | |
runs-on: ubuntu-latest | |
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 }} | |
- name: Enable corepack | |
shell: bash | |
run: corepack enable | |
- name: Set up Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 | |
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@14672906e672a08bd6eeb15720e9ed3ce869cdd4 # v2.9.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 }} |