Skip to content

Commit ea9eb7f

Browse files
committed
ci(release): automate package publishing
1 parent 64ce52e commit ea9eb7f

5 files changed

Lines changed: 2316 additions & 41 deletions

File tree

.github/workflows/publish-package.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
name: Publish Package
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
dist_tag:
7-
description: npm dist-tag
8-
required: true
9-
default: next
10-
type: choice
11-
options:
12-
- next
13-
- latest
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "DESIGN.md"
9+
- "dist/**"
10+
- "README.md"
11+
- "system/README.md"
12+
- "tokens/**"
1413

1514
concurrency:
1615
group: putio-design-publish-package
@@ -28,8 +27,10 @@ jobs:
2827
name: release
2928
url: https://www.npmjs.com/package/@putdotio/design
3029
permissions:
31-
contents: read
30+
contents: write
3231
id-token: write
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3334
steps:
3435
- name: Check out repository
3536
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -40,7 +41,6 @@ jobs:
4041
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.0.0
4142
with:
4243
node-version-file: .node-version
43-
registry-url: https://registry.npmjs.org
4444

4545
- name: Set up pnpm
4646
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
@@ -53,5 +53,5 @@ jobs:
5353
- name: Verify package and design system
5454
run: pnpm verify:full
5555

56-
- name: Publish to npm
57-
run: npm publish --provenance --access public --tag "${{ inputs.dist_tag }}"
56+
- name: Release package
57+
run: pnpm exec semantic-release

.releaserc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"branches": [
3+
"main"
4+
],
5+
"tagFormat": "v${version}",
6+
"plugins": [
7+
"@semantic-release/commit-analyzer",
8+
"@semantic-release/release-notes-generator",
9+
"@semantic-release/npm"
10+
]
11+
}

docs/DISTRIBUTION.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ Do not publish platform-native outputs from this repo in v1. Web, iOS, Android,
3030
Roku, and TV repos should consume the generic token artifacts and own their
3131
platform adapters.
3232

33-
Package publishing uses the manual `Publish Package` GitHub Actions workflow.
34-
The workflow runs `pnpm verify:full`, publishes with npm provenance, and expects
35-
npm Trusted Publishing to be configured for the `release` GitHub Environment.
36-
Use the `next` dist-tag for pre-release or adoption-test packages, and `latest`
37-
only for a release that should become the default npm install target.
33+
Package publishing uses semantic-release in the `Publish Package` GitHub Actions
34+
workflow. On `main`, design artifact changes run `pnpm verify:full` and then
35+
publish a package release when the commit history contains a releasable
36+
Conventional Commit. Commits such as `docs:` or `ci:` do not publish a package.
37+
38+
Published packages use npm provenance and the default `latest` dist-tag.
3839

3940
Before the first publish, an npm maintainer must trust this workflow for the
4041
package:

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"dtcg"
2020
],
2121
"publishConfig": {
22-
"access": "public"
22+
"access": "public",
23+
"provenance": true
2324
},
2425
"files": [
2526
"DESIGN.md",
@@ -54,8 +55,12 @@
5455
"devDependencies": {
5556
"@axe-core/playwright": "^4.11.3",
5657
"@playwright/test": "^1.60.0",
58+
"@semantic-release/commit-analyzer": "^13.0.1",
59+
"@semantic-release/npm": "^13.1.5",
60+
"@semantic-release/release-notes-generator": "^14.1.1",
5761
"@types/node": "^25.9.1",
5862
"html-validate": "^11.2.0",
63+
"semantic-release": "^25.0.3",
5964
"sst": "^4.14.3",
6065
"style-dictionary": "^5.4.1",
6166
"typescript": "^6.0.2",

0 commit comments

Comments
 (0)