Skip to content

Commit

Permalink
chore(build): Implement semantic release automation
Browse files Browse the repository at this point in the history
Automated semantic release process for better version control. Created new workflows for releasing and publishing, added `@semantic-release/*` plugins in the new `.releaserc.json` file. The package and deno versions are now determined during release, not at development stage.
  • Loading branch information
hckhanh committed Feb 28, 2024
1 parent 627299b commit b76a230
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 8 deletions.
34 changes: 29 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Publish

on:
push:
branches:
Expand All @@ -9,16 +10,39 @@ jobs:
name: Test
uses: ./.github/workflows/tests.yml
secrets: inherit
publish:
name: Publish
runs-on: ubuntu-latest
release:
name: Release
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Deno
uses: denoland/setup-deno@v1
- name: Publish package
- name: Install jq
uses: dcarbone/install-jq-action@v2
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'pnpm'
- name: Release on GitHub
run: pnpm --package conventional-changelog-conventionalcommits --package semantic-release dlx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update version in deno.json
run:
jq '.version = "${{ github.event.release.tag_name }}"' deno.json > deno.json.tmp
mv deno.json.tmp deno.json
- name: Publish package to JSR
run: deno publish
19 changes: 17 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ jobs:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Prettier check
run: pnpm test:prettier
test:
name: Unit tests
- name: Checks for known security issues with the installed packages
run: pnpm audit
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: pnpm npm audit signatures
node:
name: Node tests
needs: lints
runs-on: ubuntu-latest
strategy:
Expand All @@ -45,3 +50,13 @@ jobs:
run: pnpm install
- name: Run unit tests
run: pnpm test
deno:
name: Deno test
needs: lints
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Deno
uses: denoland/setup-deno@v1
- name: Type-check the dependencies
run: deno check src/index.ts
10 changes: 10 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"branches": ["main"],
"tagFormat": "${version}",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github"
]
}
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hckhanh/vn-number",
"version": "1.6.0",
"version": "0.0.0-development",
"exports": "./src/index.ts",
"exclude": [
".github/",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"name": "@hckhanh/vn-number",
"version": "0.0.0-development",
"description": "A bunch of utility functions that work with number in Vietnamese language",
"type": "module",
"private": true,
"sideEffects": false,
"scripts": {
"test": "vitest related src/**/*.ts",
Expand Down

0 comments on commit b76a230

Please sign in to comment.