Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: publish preview versions #2335

Merged
merged 7 commits into from
Oct 27, 2024
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/auto.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: auto

on: [push]

jobs:
cancel-previous-workflows:
runs-on: macos-latest
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/compat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/lock-closed-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: locked-closed-issues

on:
schedule:
- cron: '0 0 * * *'

permissions:
issues: write

jobs:
action:
runs-on: macos-latest
steps:
- uses: dessant/lock-threads@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
issue-inactive-days: '14'
issue-lock-reason: ''
process-only: 'issues'
60 changes: 60 additions & 0 deletions .github/workflows/release-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: release

on:
pull_request_review:
types: [submitted]
workflow_dispatch:

jobs:
check:
# Trigger the permissions check whenever someone approves a pull request.
# They must have the write permissions to the repo in order to
# trigger preview package publishing.
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
outputs:
Copy link
Member Author

Choose a reason for hiding this comment

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

Setup

The trick to a finally properly working setup was:

  • Has 2 separate jobs: one checks for permissions, the other publishes the preview;
  • The check job shares its outputs via outputs. It references the used action output based on the user's permissions. The job itself never fails because then the entire PR status will be failed, which isn't nice;
  • The preview job needs the check job BUT also needs a custom if condition since the check job won't ever fail (even if it's skipped, GitHub still treats the job status as success). In the if, the preview job can check the shared outputs from the permissions check, and publish the preview only if the output is 'true'.

has-permissions: ${{ steps.checkPermissions.outputs.require-result }}
steps:
- name: Check permissions
id: checkPermissions
uses: actions-cool/check-user-permission@v2
with:
require: 'write'

preview:
# The approving user must pass the permissions check
# to trigger the preview publish.
needs: check
if: needs.check.outputs.has-permissions == 'true'
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 8.15.6

- name: Install dependencies
run: pnpm install

- name: Install Playwright browsers
run: pnpm exec playwright install

- name: Lint
run: pnpm lint

- name: Build
run: pnpm build

- name: Tests
run: pnpm test

- name: Publish preview
run: pnpm dlx pkg-pr-new@0.0 publish --compact --pnpm --comment=update
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ jobs:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_ADMIN_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v3
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
always-auth: true
registry-url: https://registry.npmjs.org

- uses: pnpm/action-setup@v4
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 8.15.6

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

- name: Set up PNPM
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 8.15.6
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/typescript-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand All @@ -37,10 +37,10 @@ jobs:
if: ${{ needs.compare.outputs.latest_version != needs.compare.outputs.rc_version }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18

Expand Down
6 changes: 5 additions & 1 deletion decisions/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ MSW uses the [Release](https://github.com/ossjs/release) library to automate its

## Release schedule

The next version of the library releases automatically **every 3 days**.
The next version of **the library releases automatically every day**.

We do our best to choose the optimal release window to accumulate multiple changes under a single release. We do deviate from the release schedule in emergency cases, like when a critical issue has been fixed and needs an immediate release.

> [!IMPORTANT]
> Please do not ping the library maintainers to release a new version of MSW. Be patient and wait for the automated release to happen. Subscribe to any issue or pull request you are interested in, and you will be notified whenever it gets released.

## Preview releases

This repository is configured to **release work-in-progress pull requests** using [okg.pr.new](https://github.com/stackblitz-labs/pkg.pr.new). Once the pull request in question is approved, it will automatically be published to a temporary registry. Follow the instructions in the automated comment to install the work-in-progress version of the package.
Loading