Skip to content

Commit 56e6ccd

Browse files
jackwCopilot
authored andcommitted
ci: replace auto canary releases with pkg.pr.new (#2677)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent a5d4651 commit 56e6ccd

16 files changed

Lines changed: 93 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,12 @@ jobs:
516516
release:
517517
runs-on: ubuntu-latest
518518
needs: [test, generate-plugins]
519-
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci') && github.actor != 'dependabot[bot]'"
519+
if: |
520+
!contains(github.event.head_commit.message, 'ci skip')
521+
&& !contains(github.event.head_commit.message, 'skip ci')
522+
&& github.actor != 'dependabot[bot]'
523+
&& github.event_name == 'push'
524+
&& github.ref == 'refs/heads/main'
520525
name: Release packages
521526
env:
522527
NX_BRANCH: ${{ github.event.number || github.ref_name }}

.github/workflows/preview.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Preview (pkg.pr.new)
2+
on:
3+
pull_request:
4+
types: [labeled, synchronize]
5+
permissions:
6+
contents: read
7+
concurrency:
8+
group: preview-${{ github.event.pull_request.number }}
9+
cancel-in-progress: true
10+
jobs:
11+
preview:
12+
if: |
13+
(github.event.action == 'labeled' && github.event.label.name == 'preview') ||
14+
(github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'preview'))
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
19+
with:
20+
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
21+
fetch-depth: 0
22+
persist-credentials: false
23+
- uses: nrwl/nx-set-shas@afb73a62d26e41464e9254689e1fd6122ee683c1 # v5.0.1
24+
- name: Setup nodejs
25+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
26+
with:
27+
node-version-file: '.nvmrc'
28+
package-manager-cache: false
29+
30+
- name: Install dependencies
31+
run: npm ci --no-audit
32+
- name: Build all packages
33+
run: npm run build
34+
- name: Publish packages
35+
run: npm exec pkg-pr-new publish -- './packages/*' --compact --commentWithSha --commentWithDev

CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [Contribute Documentation](#contribute-documentation)
1414
- [Contribute Code](#contribute-code)
1515
- Manage Something ✅🙆🏼💃👔
16+
- [Preview Your Changes Before Release](#preview-your-changes-before-release)
1617
- [Create a Release](#create-a-release)
1718
- [Release Version Calculation](#release-version-calculation)
1819
- [Help! The release failed after the packages were published to the NPM registry](#help-the-release-failed-after-the-packages-were-published-to-the-npm-registry)
@@ -160,6 +161,33 @@ Once you've filed the PR:
160161
- If the maintainer decides to pass on your PR, they will thank you for the contribution and explain why they won't be accepting the changes. That's okay! We still really appreciate you taking the time to do it, and we don't take that lightly. 💚
161162
- If your PR gets accepted, it will be marked as such, and merged into the `main` branch soon after. Your contribution will be distributed to the masses next time the maintainers [create a release](#create-a-release)
162163

164+
## Preview Your Changes Before Release
165+
166+
Whilst developing new features it's possible to publish and install preview builds of every affected package using [pkg.pr.new](https://pkg.pr.new) — a free open-source service that builds and hosts SHA-keyed npm tarballs.
167+
168+
To opt in:
169+
170+
1. Add the `preview` label to your PR.
171+
2. CI builds every workspace and publishes the affected packages to pkg.pr.new.
172+
3. The [`pkg-pr-new[bot]`](https://github.com/apps/pkg-pr-new) posts a comment on the PR with one installable URL per affected package.
173+
174+
Consumers install the preview by URL:
175+
176+
```bash
177+
npm i https://pkg.pr.new/grafana/plugin-tools/@grafana/<package-name>@<commit-sha>
178+
```
179+
180+
For CLI packages (`create-plugin`, `plugin-docs-cli`, `plugin-meta-extractor`, `plugin-types-bundler`, `react-detect`, `sign-plugin`), you can also run the binary directly without installing:
181+
182+
```bash
183+
npx https://pkg.pr.new/grafana/plugin-tools/@grafana/<cli-package>@<commit-sha>
184+
```
185+
186+
> [!IMPORTANT]
187+
> The URL keys off the commit SHA, not a real semver version. Any `package.json` reference to a pkg.pr.new URL must be swapped back to the published version once the PR is merged and released.
188+
189+
When you push new commits to a PR with the `preview` label, the existing pkg.pr.new comment is updated in place with the new commit SHA.
190+
163191
## Create A Release
164192

165193
Releases are managed by [Auto](https://intuit.github.io/auto/index) and PR labels.

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"husky": "^9.1.7",
5656
"lerna": "^9.0.3",
5757
"lint-staged": "^16.2.7",
58+
"pkg-pr-new": "^0.0.75",
5859
"prettier": "3.8.3",
5960
"publint": "^0.3.12",
6061
"rollup": "^4.57.1",

packages/create-plugin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "@grafana/create-plugin",
33
"version": "7.6.2",
44
"repository": {
5+
"type": "git",
56
"directory": "packages/create-plugin",
67
"url": "https://github.com/grafana/plugin-tools"
78
},

packages/eslint-plugin-plugins/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
],
2626
"homepage": "https://www.npmjs.com/package/@grafana/eslint-plugin-plugins",
2727
"repository": {
28+
"type": "git",
2829
"directory": "packages/eslint-plugin-plugins",
2930
"url": "git+https://github.com/grafana/plugin-tools.git"
3031
},

packages/plugin-docs-cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"CHANGELOG.md"
1212
],
1313
"repository": {
14+
"type": "git",
1415
"directory": "packages/plugin-docs-cli",
1516
"url": "https://github.com/grafana/plugin-tools"
1617
},

packages/plugin-docs-parser/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"CHANGELOG.md"
1313
],
1414
"repository": {
15+
"type": "git",
1516
"directory": "packages/plugin-docs-parser",
1617
"url": "https://github.com/grafana/plugin-tools"
1718
},

packages/plugin-e2e/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ Beware that scenarios provided by @grafana/plugin-e2e needs to be work in older
115115

116116
3. Push the changes in your local PR, create a draft PR in [grafana/plugin-tools](https://github.com/grafana/plugin-tools/) and add the labels `release` and `minor|patch`. CI will run all Playwright tests against a set of different Grafana versions. If not all of them pass, it may be because you've introduced a change that is no longer compatible with older versions of Grafana.
117117

118-
4. Once CI passes, `auto` will publish a canary release to NPM. You can find the version number at the bottom of the PR description.
118+
4. Add the **`preview`** label to your PR. [pkg.pr.new](https://pkg.pr.new) will post a comment with an installable preview URL for `@grafana/plugin-e2e` (and any other affected packages). See [Preview Your Changes Before Release](../../CONTRIBUTING.md#preview-your-changes-before-release) in the root `CONTRIBUTING.md` for details.
119119

120120
5. Install the pre-release of @grafana/plugin-e2e in [grafana/grafana](https://github.com/grafana/grafana) and run Playwright tests.
121121

122122
```bash
123123
# In your local grafana development folder
124-
yarn add @grafana/plugin-e2e@0.3.0-canary.623.aedff75.0
124+
yarn add https://pkg.pr.new/grafana/plugin-tools/@grafana/plugin-e2e@<commit-sha>
125125
yarn e2e:plugin
126126
```
127127

0 commit comments

Comments
 (0)