Skip to content

Commit

Permalink
feat: add semantic-release automation (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel-Develops authored Nov 6, 2024
1 parent 63ed080 commit 314719b
Show file tree
Hide file tree
Showing 5 changed files with 3,312 additions and 25 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: PR Title
on:
pull_request_target:
types: [opened, edited, synchronize, reopened]

permissions:
pull-requests: write

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Validate PR title
uses: amannn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure which types are allowed
types: |
feat
fix
chore
docs
style
refactor
perf
test
ci
revert
# To indicate breaking changes use the `!` symbol. e.g refactor!: Drop support for Node.js 12
# Configure which scopes are allowed
# scopes: |
# core
# ui
# Configure that a scope must always be provided
requireScope: false
# Configure additional validation for the subject based on a regex.
# This example ensures the subject doesn't start with an uppercase character.
subjectPattern: ^(?![A-Z]).+$
# If `subjectPattern` is configured, you can use this property to override
# the default error message that is shown when the pattern doesn't match.
# The variables `subject` and `title` can be used within the message.
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.
# For work-in-progress PRs you can typically use draft pull requests
# from GitHub. However, private repositories on the free plan don't have
# this option and therefore this action allows you to opt-in to using the
# special "[WIP]" prefix to indicate this state. This will avoid the
# validation of the PR title and the pull request checks remain pending.
# Note that a second check will be reported if this is enabled.
wip: true
# When using "Squash and merge" on a PR with only one commit, GitHub
# will suggest using that commit message instead of the PR title for the
# merge commit, and it's easy to commit this by mistake. Enable this
# option to also validate the commit message for one commit PRs.
validateSingleCommit: true
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:

jobs:
release:
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install dependencies
run: yarn install --immutable

- name: Build project
run: yarn build

- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"start": "next start",
"lint": "next lint"
},
"engines": {
"node": ">=20.13.1 <21"
},
"dependencies": {
"@chakra-ui/react": "^2.4.9",
"@elastic/elasticsearch": "^8.8.1",
Expand Down Expand Up @@ -51,10 +54,16 @@
"webln": "^0.3.2"
},
"devDependencies": {
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^13.0.0",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^11.0.0",
"@semantic-release/release-notes-generator": "^14.0.1",
"@types/next": "^9.0.0",
"@types/react-syntax-highlighter": "^15.5.13",
"@types/uuid": "^9.0.1",
"next-transpile-modules": "^10.0.0",
"semantic-release": "^24.2.0",
"webpack": "^5.86.0"
}
}
16 changes: 16 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
branches: ["main"],
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
'@semantic-release/changelog',
"@semantic-release/github",
[
"@semantic-release/git",
{
message:
"chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
},
],
],
};
Loading

0 comments on commit 314719b

Please sign in to comment.