Skip to content

chore: Add release action #5

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

Merged
merged 11 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release
on:
workflow_dispatch: # manual trigger

permissions:
contents: read # for checkout

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install dependencies
run: yarn install --immutable
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }}
run: npx semantic-release --dry-run

Choose a reason for hiding this comment

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

Should this still have --dry-run?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. Removed that, and removed cc/releasing from the releaserc branches section.

49 changes: 49 additions & 0 deletions .github/workflows/validate-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "Lint PR"

on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened

permissions:
pull-requests: write

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
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.

```
feat: Add variant `outlined` to Button component
feat!: Remove variant `filled` from Button component
bug: Fix TextField hover efffect.
```
*Note: `!` denotes a breaking change*.

Action failure details:
```
${{ steps.lint_pr_title.outputs.error_message }}
```

# Delete a previous comment when the issue has been resolved
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
delete: true
40 changes: 40 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"branches": ["+([0-9])?(.{+([0-9]),x}).x", "main", "cc/releasing"],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"section": "Miscellaneous"
},
{
"type": "docs",
"section": "Miscellaneous"
}
]
}
}
],
"@semantic-release/github",
"@semantic-release/npm"
],
"repositoryUrl": "git@github.com:mitodl/smoot-design.git"
}
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# smoot-design

Design system components for MITODL Projects

## Development and Release

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.

To trigger a release, run the "Release" github action. Using [semantic-release](https://semantic-release.gitbook.io/semantic-release), this action will:

1. Inspect the commit history since previous release for [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) an
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.
3. Publish the package to NPM and the repository's [Github Releases](https://github.com/mitodl/smoot-design/releases).
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"name": "@mitodl/smoot-design",
"version": "0.0.0",
"packageManager": "yarn@4.5.1",
"repository": {
"type": "git",
"url": "https://github.com/mitodl/smoot-design"
},
"scripts": {
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build --docs",
Expand Down Expand Up @@ -69,6 +73,7 @@
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/typescript-estree": "^8.13.0",
"conventional-changelog-conventionalcommits": "^8.0.0",
"eslint": "8.57.1",
"eslint-config-mitodl": "^2.1.0",
"eslint-config-prettier": "^9.0.0",
Expand All @@ -91,6 +96,7 @@
"react-dom": "^18.3.1",
"react-router": "^6.22.2",
"react-router-dom": "^6.22.2",
"semantic-release": "^24.2.0",
"storybook": "^8.4.2",
"ts-node": "^10.9.2",
"tsconfig-paths-webpack-plugin": "^4.1.0",
Expand Down
Loading