Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 14 additions & 40 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@
name: prerelease
on:
push:
branches:
# releases/<tag>/<version>
- releases/*/*
branches: [main]
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
prerelease:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
runs-on: ubuntu-slim
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false

- name: Read primary Node version
id: node
run: echo "version=$(yq eval '.primary_node_version' .github/test-matrix.yml)" >> "$GITHUB_OUTPUT"

- uses: actions/setup-node@v6
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ steps.node.outputs.version }}
cache: npm
registry-url: 'https://registry.npmjs.org'

# Use npm@10 due to https://github.com/npm/cli/issues/8489 and https://github.com/npm/cli/issues/8767
- name: Setup npm version
Expand All @@ -34,33 +36,5 @@ jobs:
- name: Build project
run: npm run build

- name: Extract tag and version
id: extract
run: |-
ref=${{ github.ref }}
branch=${ref:11}
tag_version=${branch:9}
tag=${tag_version%/*}
version=${tag_version##*/}
echo "tag=${tag}" >> $GITHUB_OUTPUT
echo "version=${version}" >> $GITHUB_OUTPUT
- name: Log versions
run: |-
echo tag=${{ steps.extract.outputs.tag }}
echo version=${{ steps.extract.outputs.version }}

- name: Configure Git user
run: |
git config --global user.name "Netlify"
git config --global user.email "82042599+token-generator-app[bot]@users.noreply.github.com"

- name: Run npm version
run: npm version ${{ steps.extract.outputs.version }}-${{ steps.extract.outputs.tag }} --allow-same-version

- name: Push changes
run: git push --follow-tags

- name: Run npm publish
run: npm publish --tag=${{ steps.extract.outputs.tag }} --provenance
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Publish prerelease
run: npm exec -- pkg-pr-new publish

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add previewVersion to prerelease publishes

Because this replaces the old flow that ran npm version <version>-<tag> before publishing, invoking pkg-pr-new publish without --previewVersion packs previews with the unchanged source version from package.json (currently 27.1.0). When someone installs a PR/main preview into a project, the lockfile and netlify --version/telemetry identify it as the real release version, and lockfiles can keep resolving that same-version preview tarball even after the actual npm release; pass --previewVersion so each preview gets a distinct preview version.

Useful? React with 👍 / 👎.

7 changes: 2 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,8 @@

### Creating a prerelease

1. Create a branch named `releases/<tag>/<version>` with the version and tag you’d like to release.
2. Push the branch to the repo.

For example, a branch named `releases/rc.0/4.0.0` will create the version `4.0.0-rc.0` and publish it under the `rc.0`
tag.
Pull requests and pushes to `main` automatically publish installable prereleases with [pkg.pr.new](https://pkg.pr.new/).

Check warning on line 208 in CONTRIBUTING.md

View workflow job for this annotation

GitHub Actions / lint-docs

[vale] reported by reviewdog 🐶 [base.spelling] Spellcheck: did you really mean 'prereleases'? Raw Output: {"message": "[base.spelling] Spellcheck: did you really mean 'prereleases'?", "location": {"path": "CONTRIBUTING.md", "range": {"start": {"line": 208, "column": 70}}}, "severity": "WARNING"}
Check the prerelease workflow run for the package version and installation command.
Comment thread
serhalp marked this conversation as resolved.

## License

Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
"npm-run-all2": "^8.0.4",
"p-timeout": "^7.0.0",
"picomatch": "^4.0.4",
"pkg-pr-new": "^0.0.86",
"prettier": "^2.8.8",
"serialize-javascript": "^7.0.5",
"strip-ansi": "^7.1.2",
Expand Down
Loading