Skip to content

Commit 0190d24

Browse files
committed
chore: add git flow
1 parent 7e6af39 commit 0190d24

File tree

5 files changed

+173
-0
lines changed

5 files changed

+173
-0
lines changed

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
# -------- pnpm + cache ----------
16+
- uses: pnpm/action-setup@v4 # installs pnpm (reads version from package.json if present)
17+
- uses: actions/setup-node@v4
18+
with:
19+
node-version: 20 # single version is fine for lint
20+
cache: 'pnpm' # enables automatic pnpm-store caching
21+
22+
- run: pnpm install --frozen-lockfile
23+
- run: pnpm run lint
24+
25+
build:
26+
needs: lint
27+
runs-on: ubuntu-latest
28+
strategy:
29+
matrix:
30+
node-version: [18.x, 20.x, 22.x] # stable Node versions
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
# -------- pnpm + cache ----------
35+
- uses: pnpm/action-setup@v4
36+
- uses: actions/setup-node@v4
37+
with:
38+
node-version: ${{ matrix.node-version }}
39+
cache: 'pnpm'
40+
41+
- run: pnpm install --frozen-lockfile
42+
- run: pnpm run build
43+
44+
test:
45+
needs: build
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
# -------- pnpm + cache ----------
51+
- uses: pnpm/action-setup@v4
52+
- uses: actions/setup-node@v4
53+
with:
54+
node-version: 20
55+
cache: 'pnpm'
56+
57+
- run: pnpm install --frozen-lockfile
58+
- run: pnpm run test

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch: # manual trigger
5+
push:
6+
branches: [master] # assumes your main branch is master
7+
8+
concurrency:
9+
group: release # never run two releases in parallel
10+
cancel-in-progress: true
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write # needed for pushing version commits & creating releases
17+
issues: write # needed for commenting on issues
18+
pull-requests: write # needed for commenting on PRs
19+
id-token: write # needed for npm provenance
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0 # semantic-release needs full history & tags
25+
persist-credentials: false # use GitHub token with correct permissions
26+
27+
# -------- pnpm + node (same cache strategy used in CI) ----
28+
- uses: pnpm/action-setup@v4
29+
- uses: actions/setup-node@v4
30+
with:
31+
node-version: 20
32+
cache: 'pnpm'
33+
registry-url: 'https://registry.npmjs.org'
34+
provenance: true
35+
36+
- run: pnpm install --frozen-lockfile
37+
38+
# (optional) run tests / build again for extra safety
39+
- run: pnpm run test
40+
- run: pnpm run build
41+
42+
# -------- install semantic-release and plugins --------
43+
- name: Install semantic-release
44+
run: pnpm add -D semantic-release @semantic-release/changelog @semantic-release/git conventional-changelog-conventionalcommits
45+
46+
# -------- run release --------
47+
- name: Run semantic-release
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
51+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
52+
NPM_CONFIG_PROVENANCE: true
53+
run: npx semantic-release

.github/workflows/semantics.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: PR Semantics
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, reopened, synchronize]
6+
7+
jobs:
8+
semantics:
9+
name: Semantics
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: 8BitJonny/gh-get-current-pr@2.2.0
13+
id: pull-request
14+
with:
15+
sha: ${{ github.head_ref }}
16+
17+
- name: Add Commit Lint
18+
if: ${{ steps.pull-request.outputs.pr_found == 'true' }}
19+
run: |
20+
npm init -y
21+
npm install --save-dev @commitlint/cli @commitlint/config-angular
22+
echo "module.exports = { \
23+
extends: ['@commitlint/config-angular'], \
24+
rules: { \
25+
'subject-empty': [2, 'never'], \
26+
'scope-empty' : [2, 'never'], \
27+
'type-case' : [2, 'always', 'lower-case'], \
28+
'type-empty' : [2, 'never'], \
29+
'type-enum' : [2, 'always', ['chore','feat','fix','refactor']], \
30+
'scope-enum' : [2, 'always', ['openapi']] \
31+
} \
32+
};" > commitlint.config.js
33+
34+
- name: Validate Semantic Title
35+
if: ${{ steps.pull-request.outputs.pr_found == 'true' }}
36+
run: |
37+
echo "${{ steps.pull-request.outputs.pr_title }}" | npx commitlint
38+
39+
- name: Get Semantic Commit Scope
40+
if: ${{ steps.pull-request.outputs.pr_found == 'true' }}
41+
id: scope
42+
run: |
43+
echo "name=$(echo '${{ steps.pull-request.outputs.pr_title }}' | cut -d'(' -f1)" >> $GITHUB_OUTPUT

.releaserc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"branches": ["master"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
["@semantic-release/release-notes-generator", { "preset": "conventionalcommits" }],
6+
"@semantic-release/changelog",
7+
["@semantic-release/npm", {
8+
"provenance": true
9+
}],
10+
["@semantic-release/git", {
11+
"assets": ["CHANGELOG.md", "package.json", "pnpm-lock.yaml"],
12+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
13+
}],
14+
"@semantic-release/github"
15+
]
16+
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

0 commit comments

Comments
 (0)