Skip to content

Commit 09c2847

Browse files
chore: Add release action (#5)
1 parent 2cd347b commit 09c2847

File tree

6 files changed

+3099
-125
lines changed

6 files changed

+3099
-125
lines changed

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release
2+
on:
3+
workflow_dispatch: # manual trigger
4+
5+
permissions:
6+
contents: read # for checkout
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write # to be able to publish a GitHub release
14+
issues: write # to be able to comment on released issues
15+
pull-requests: write # to be able to comment on released pull requests
16+
id-token: write # to enable use of OIDC for npm provenance
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: "lts/*"
26+
- name: Install dependencies
27+
run: yarn install --immutable
28+
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
29+
run: npm audit signatures
30+
- name: Release
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
33+
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
34+
run: npx semantic-release

.github/workflows/validate-pr.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "Lint PR"
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
- reopened
10+
11+
permissions:
12+
pull-requests: write
13+
14+
jobs:
15+
main:
16+
name: Validate PR title
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: amannn/action-semantic-pull-request@v5
20+
id: lint_pr_title
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
- uses: marocchino/sticky-pull-request-comment@v2
24+
# When the previous steps fails, the workflow would stop. By adding this
25+
# condition you can continue the execution with the populated error message.
26+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
27+
with:
28+
header: pr-title-lint-error
29+
message: |
30+
Please ensure that your PR title follows [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). It looks like your proposed title needs to be adjusted.
31+
32+
```
33+
feat: Add variant `outlined` to Button component
34+
feat!: Remove variant `filled` from Button component
35+
bug: Fix TextField hover efffect.
36+
```
37+
*Note: `!` denotes a breaking change*.
38+
39+
Action failure details:
40+
```
41+
${{ steps.lint_pr_title.outputs.error_message }}
42+
```
43+
44+
# Delete a previous comment when the issue has been resolved
45+
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
46+
uses: marocchino/sticky-pull-request-comment@v2
47+
with:
48+
header: pr-title-lint-error
49+
delete: true

.releaserc.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"branches": ["+([0-9])?(.{+([0-9]),x}).x", "main"],
3+
"plugins": [
4+
[
5+
"@semantic-release/commit-analyzer",
6+
{
7+
"preset": "conventionalcommits"
8+
}
9+
],
10+
[
11+
"@semantic-release/release-notes-generator",
12+
{
13+
"preset": "conventionalcommits",
14+
"presetConfig": {
15+
"types": [
16+
{
17+
"type": "feat",
18+
"section": "Features"
19+
},
20+
{
21+
"type": "fix",
22+
"section": "Bug Fixes"
23+
},
24+
{
25+
"type": "chore",
26+
"section": "Miscellaneous"
27+
},
28+
{
29+
"type": "docs",
30+
"section": "Miscellaneous"
31+
}
32+
]
33+
}
34+
}
35+
],
36+
"@semantic-release/github",
37+
"@semantic-release/npm"
38+
],
39+
"repositoryUrl": "git@github.com:mitodl/smoot-design.git"
40+
}

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
# smoot-design
22

33
Design system components for MITODL Projects
4+
5+
## Development and Release
6+
7+
All PR titles and commits to `main` should use the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) format. During release, the types of commits included since the last release inform what sort of version bump should be made. For example, bugfixes yield a new patch version, whereas breaking changes trigger a major version bump.
8+
9+
To trigger a release, run the "Release" github action. Using [semantic-release](https://semantic-release.gitbook.io/semantic-release), this action will:
10+
11+
1. Inspect the commit history since previous release for [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) an
12+
2. Determine whether the version bump should be major, minor, or patch based on commit types. Breaking changes (e.g., `feat!: remove Button variant 'outlined'`) will result in major version bumps.
13+
3. Publish the package to NPM and the repository's [Github Releases](https://github.com/mitodl/smoot-design/releases).

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
"name": "@mitodl/smoot-design",
33
"version": "0.0.0",
44
"packageManager": "yarn@4.5.1",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/mitodl/smoot-design"
8+
},
59
"scripts": {
610
"storybook": "storybook dev -p 6006",
711
"build-storybook": "storybook build --docs",
@@ -69,6 +73,7 @@
6973
"@types/react-dom": "^18.3.0",
7074
"@typescript-eslint/eslint-plugin": "^8.13.0",
7175
"@typescript-eslint/typescript-estree": "^8.13.0",
76+
"conventional-changelog-conventionalcommits": "^8.0.0",
7277
"eslint": "8.57.1",
7378
"eslint-config-mitodl": "^2.1.0",
7479
"eslint-config-prettier": "^9.0.0",
@@ -91,6 +96,7 @@
9196
"react-dom": "^18.3.1",
9297
"react-router": "^6.22.2",
9398
"react-router-dom": "^6.22.2",
99+
"semantic-release": "^24.2.0",
94100
"storybook": "^8.4.2",
95101
"ts-node": "^10.9.2",
96102
"tsconfig-paths-webpack-plugin": "^4.1.0",

0 commit comments

Comments
 (0)