Skip to content

Commit

Permalink
chore: add semantic-release, update actions
Browse files Browse the repository at this point in the history
- Add Semantic Release
- Add commitlint
- Add Husky pre-commit rules
  - Enforce conventional commits
  - Enforce lint rules
- Update Automated tests action
- Update Dependabot
  • Loading branch information
zanix committed Mar 10, 2024
1 parent fdfe249 commit 8393521
Show file tree
Hide file tree
Showing 9 changed files with 1,716 additions and 78 deletions.
3 changes: 3 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@commitlint/config-conventional"
}
4 changes: 2 additions & 2 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
interval: "weekly"

- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
interval: "weekly"
21 changes: 8 additions & 13 deletions .github/workflows/automated-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Automated Tests

on:
push:
branches: [main, develop]
Expand All @@ -13,20 +14,14 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4.1.1
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: Use Node.js
- name: 📥 Check out repository
uses: actions/checkout@v4
- name: 📜 Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
- name: Install dependencies and run tests
run: |
npm install
npm run lint
- run: echo "🍏 This job's status is ${{ job.status }}."
- name: 🔗 Install dependencies
run: npm install
- name: 🧹 Lint
run: npm run lint
41 changes: 41 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release

on:
push:
branches: [main, develop]

permissions:
contents: read

jobs:
release:
name: Release
runs-on: ubuntu-latest

permissions:
contents: write
issues: write
pull-requests: write
id-token: write

steps:
- name: 📥 Check out repository
uses: actions/checkout@v4
- name: 📜 Use Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: 🔗 Install dependencies
run: npx ci
- name: 🧩 Install semantic-release extra plugins
run: npm install --save-dev @semantic-release/changelog @semantic-release/git
- name: 🧹 Lint
run: npm run lint:fix
- name: 🧪 Test
run: npm run test:unit --if-present
- name: 🛠️ Build
run: npm run build
- name: ✅ Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
2 changes: 2 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
npx --no -- commitlint --edit "$1"
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
npx lint-staged
21 changes: 21 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
"@semantic-release/github",
[
"@semantic-release/git",
{
"assets": ["package.json", "CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
Loading

0 comments on commit 8393521

Please sign in to comment.