(Runtime) Publish Releases from NPM Manual #10
This file contains hidden or 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: (Runtime) Publish Releases from NPM Manual | |
on: | |
workflow_dispatch: | |
inputs: | |
version_to_promote: | |
required: true | |
description: Current npm version (non-experimental) to promote | |
type: string | |
version_to_publish: | |
required: true | |
description: Version to publish for the specified packages | |
type: string | |
only_packages: | |
description: Packages to publish (space separated) | |
type: string | |
skip_packages: | |
description: Packages to NOT publish (space separated) | |
type: string | |
tags: | |
description: NPM tags (space separated) | |
type: string | |
default: untagged | |
dry: | |
required: true | |
description: Dry run instead of publish? | |
type: boolean | |
default: true | |
force_notify: | |
description: Force a Discord notification? | |
type: boolean | |
default: false | |
env: | |
TZ: /usr/share/zoneinfo/America/Los_Angeles | |
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout | |
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 1 | |
GH_TOKEN: ${{ github.token }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
jobs: | |
notify: | |
if: ${{ inputs.force_notify || inputs.dry == false || inputs.dry == 'false' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Discord Webhook Action | |
uses: tsickert/discord-webhook@v6.0.0 | |
with: | |
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
embed-author-name: ${{ github.event.sender.login }} | |
embed-author-url: ${{ github.event.sender.html_url }} | |
embed-author-icon-url: ${{ github.event.sender.avatar_url }} | |
embed-title: '⚠️ Publishing release from NPM' | |
embed-description: | | |
```json | |
${{ toJson(inputs) }} | |
``` | |
embed-url: https://github.com/facebook/react/actions/runs/${{ github.run_id }} | |
publish: | |
name: Publish releases | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: yarn | |
cache-dependency-path: yarn.lock | |
- name: Restore cached node_modules | |
uses: actions/cache@v4 | |
id: node_modules | |
with: | |
path: "**/node_modules" | |
key: runtime-release-node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock', 'scripts/release/yarn.lock') }} | |
- name: Ensure clean build directory | |
run: rm -rf build | |
- run: yarn install --frozen-lockfile | |
- run: yarn install --frozen-lockfile | |
working-directory: scripts/release | |
- run: cp ./scripts/release/ci-npmrc ~/.npmrc | |
- if: '${{ inputs.only_packages }}' | |
name: 'Prepare and publish ${{ inputs.only_packages }}' | |
run: | | |
echo -e "===== Preparing release from NPM =====\n" | |
scripts/release/prepare-release-from-npm.js \ | |
--ci \ | |
--skipTests \ | |
--version=${{ inputs.version_to_promote }} \ | |
--publishVersion=${{ inputs.version_to_publish }} \ | |
--onlyPackages=${{ inputs.only_packages }} | |
echo -e "\n\n===== Check prepared files =====\n" | |
ls -R build/node_modules | |
echo -e "\n\n===== Publishing to NPM =====\n" | |
scripts/release/publish.js \ | |
--ci \ | |
--tags=${{ inputs.tags }} \ | |
--publishVersion=${{ inputs.version_to_publish }} \ | |
--onlyPackages=${{ inputs.only_packages }} \ | |
--dry=${{ inputs.dry }} | |
- if: '${{ inputs.skip_packages }}' | |
name: 'Prepare and publish all packages EXCEPT ${{ inputs.skip_packages }}' | |
run: | | |
echo -e "===== Preparing release from NPM =====\n" | |
scripts/release/prepare-release-from-npm.js \ | |
--ci \ | |
--skipTests \ | |
--version=${{ inputs.version_to_promote }} \ | |
--publishVersion=${{ inputs.version_to_publish }} \ | |
--skipPackages=${{ inputs.skip_packages }} | |
echo -e "\n\n===== Check prepared files =====\n" | |
ls -R build/node_modules | |
echo -e "\n\n===== Publishing to NPM =====\n" | |
scripts/release/publish.js \ | |
--ci \ | |
--tags=${{ inputs.tags }} \ | |
--publishVersion=${{ inputs.version_to_publish }} \ | |
--skipPackages=${{ inputs.skip_packages }} \ | |
--dry=${{ inputs.dry }} |