Skip to content

Commit ffd98bc

Browse files
plugin-typings: Add staged npm release workflows
1 parent 9d38b42 commit ffd98bc

10 files changed

Lines changed: 550 additions & 25 deletions

File tree

‎.github/RELEASING.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Releasing @figma/plugin-typings
2+
3+
Prepare the package version and `releases/X.Y.Z.md` notes in a reviewed pull request.
4+
Confirm the API changes are available to users before releasing.
5+
6+
1. Run `npm ci --ignore-scripts` and `npm run release:check`. This packs and tests
7+
the package without publishing. CI runs the same checks on pull requests.
8+
2. After review and merge, run Release (`release.yml`) on `main` with the exact
9+
version and `dry_run=true`. Inspect the package artifact and test results.
10+
3. When ready, run Release again with `dry_run=false`. A release maintainer
11+
approves the `npm-release` environment. The workflow stages the tested tarball.
12+
4. A package maintainer reviews the staged package on npm and completes approval
13+
with 2FA. Record the successful Release run ID. If staging succeeded but a later
14+
step failed, inspect the existing npm stage before retrying.
15+
5. Once the version is live, run Finalize Release (`finalize.yml`) on `main` with
16+
the version and Release run ID. It checks the npm package, provenance metadata,
17+
tarball integrity, and source commit before creating `vX.Y.Z` and the release.
18+
19+
Do not rename `release.yml` or its `npm-release` environment: npm trusted publishing
20+
uses both identifiers. Staging runs directly in this workflow.
21+
22+
Finalization can be retried after a partial failure. It accepts an existing tag
23+
only at the same commit and leaves an existing published release unchanged.
24+
Artifacts expire after 90 days; finish the release within that window. If an
25+
artifact is unavailable or verification fails, stop and ask a maintainer to
26+
investigate. Do not move an existing version tag.

‎.github/workflows/finalize.yml‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Finalize Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'Published version (X.Y.Z)'
7+
required: true
8+
type: string
9+
release_run_id:
10+
description: 'Successful Release workflow run that staged this version'
11+
required: true
12+
type: string
13+
permissions:
14+
contents: read
15+
concurrency:
16+
group: npm-release
17+
cancel-in-progress: false
18+
jobs:
19+
finalize:
20+
if: github.ref == 'refs/heads/main'
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 10
23+
permissions:
24+
contents: write
25+
actions: read
26+
steps:
27+
- uses: figma/actions-checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
28+
with:
29+
fetch-depth: 0
30+
persist-credentials: false
31+
- uses: figma/actions-setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
32+
with:
33+
node-version: '22.22.0'
34+
- name: Download release artifact
35+
env:
36+
GH_TOKEN: ${{ github.token }}
37+
RELEASE_RUN_ID: ${{ inputs.release_run_id }}
38+
run: |
39+
[[ "$RELEASE_RUN_ID" =~ ^[0-9]+$ ]]
40+
ATTEMPT=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs/$RELEASE_RUN_ID" --jq .run_attempt)
41+
[[ "$ATTEMPT" =~ ^[0-9]+$ ]]
42+
gh run download "$RELEASE_RUN_ID" --repo "$GITHUB_REPOSITORY" --name "npm-package-$RELEASE_RUN_ID-$ATTEMPT" --dir .release
43+
- name: Verify publication and finalize
44+
env:
45+
GH_TOKEN: ${{ github.token }}
46+
RELEASE_VERSION: ${{ inputs.version }}
47+
RELEASE_RUN_ID: ${{ inputs.release_run_id }}
48+
run: node scripts/release.mjs finalize

‎.github/workflows/release.yml‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'Exact package version (X.Y.Z)'
7+
required: true
8+
type: string
9+
dry_run:
10+
description: 'Test and pack only'
11+
required: true
12+
default: true
13+
type: boolean
14+
permissions:
15+
contents: read
16+
concurrency:
17+
group: npm-release
18+
cancel-in-progress: false
19+
jobs:
20+
prepare:
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 15
23+
steps:
24+
- name: Check release ref
25+
if: ${{ !inputs.dry_run && github.ref != 'refs/heads/main' }}
26+
run: exit 1
27+
- uses: figma/actions-checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
28+
with:
29+
persist-credentials: false
30+
- uses: figma/actions-setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
31+
with:
32+
node-version: '22.22.0'
33+
- run: npm ci --ignore-scripts
34+
- run: npm run release:check
35+
env:
36+
RELEASE_VERSION: ${{ inputs.version }}
37+
RELEASE_DRY_RUN: ${{ inputs.dry_run }}
38+
- name: Check version availability
39+
if: ${{ !inputs.dry_run }}
40+
run: node scripts/release.mjs available
41+
- uses: figma/actions-upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
42+
with:
43+
name: npm-package-${{ github.run_id }}-${{ github.run_attempt }}
44+
path: |
45+
.release/package.tgz
46+
.release/release.json
47+
.release/notes.md
48+
include-hidden-files: true
49+
if-no-files-found: error
50+
retention-days: 90
51+
stage:
52+
needs: prepare
53+
if: ${{ !inputs.dry_run && github.ref == 'refs/heads/main' }}
54+
runs-on: ubuntu-latest
55+
timeout-minutes: 10
56+
environment: npm-release
57+
permissions:
58+
contents: read
59+
id-token: write
60+
steps:
61+
- uses: figma/actions-checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
62+
with:
63+
persist-credentials: false
64+
- uses: figma/actions-setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
65+
with:
66+
node-version: '22.22.0'
67+
- uses: figma/actions-download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4
68+
with:
69+
name: npm-package-${{ github.run_id }}-${{ github.run_attempt }}
70+
path: .release/
71+
- run: npm install --global npm@11.15.0 --ignore-scripts --registry=https://registry.npmjs.org
72+
- run: node scripts/release.mjs verify
73+
- run: node scripts/release.mjs available
74+
- name: Stage package
75+
run: |
76+
npm stage publish .release/package.tgz --ignore-scripts --access public --provenance --tag latest --registry=https://registry.npmjs.org
77+
echo 'Package staged. Awaiting maintainer approval on npm.' >> "$GITHUB_STEP_SUMMARY"

‎.github/workflows/test.yml‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
name: CI
2-
on: [push]
2+
on: [push, pull_request]
3+
permissions:
4+
contents: read
35
jobs:
4-
test-typings-compile:
6+
test-package:
57
runs-on: ubuntu-latest
8+
timeout-minutes: 15
69
steps:
7-
- name: Check out repository code
8-
uses: actions/checkout@v4
9-
- run: npm install typescript
10-
- run: npm test
11-
- run: npm run prettier:check
12-
13-
test-usage-script:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Check out repository code
17-
uses: actions/checkout@v4
18-
- run: ./test-usage.sh
10+
- uses: figma/actions-checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
11+
with:
12+
persist-credentials: false
13+
- uses: figma/actions-setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
14+
with:
15+
node-version: '22.22.0'
16+
- run: npm ci --ignore-scripts
17+
- run: npm run release:check
18+
env:
19+
RELEASE_DRY_RUN: 'true'

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
2-
package-lock.json
32
test-artifacts
3+
4+
.release/

‎package-lock.json‎

Lines changed: 47 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: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"prettier:check": "npm run prettier-path:check -- '**/*.{ts,js}'",
99
"prettier-path": "prettier --write",
1010
"prettier-path:check": "prettier --check",
11-
"test": "tsc"
11+
"test": "tsc",
12+
"release:check": "node --test scripts/release.test.mjs && node scripts/release.mjs pack && bash test-usage.sh .release/package.tgz && npm run prettier:check"
1213
},
1314
"repository": {
1415
"type": "git",
@@ -26,6 +27,12 @@
2627
},
2728
"homepage": "https://github.com/figma/plugin-typings#readme",
2829
"devDependencies": {
29-
"prettier": "3.9.3"
30-
}
30+
"prettier": "3.9.3",
31+
"typescript": "^5.9.3"
32+
},
33+
"files": [
34+
"index.d.ts",
35+
"plugin-api.d.ts",
36+
"plugin-api-standalone.d.ts"
37+
]
3138
}

0 commit comments

Comments
 (0)