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 dc776a8
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 6 deletions.
32 changes: 27 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,37 @@ 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: 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: Install Deno
uses: denoland/setup-deno@v1
- name: Publish package
- name: Install jq
uses: dcarbone/install-jq-action@v2.1.0
- 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
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ 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
- 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
test:
name: Unit tests
needs: lints
Expand Down
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 dc776a8

Please sign in to comment.