Skip to content

Commit a63ff9a

Browse files
committed
feat: Add automated releases and tests
1 parent 1b40e34 commit a63ff9a

File tree

13 files changed

+15969
-1202
lines changed

13 files changed

+15969
-1202
lines changed

.github/workflows/release.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release
2+
3+
on:
4+
merge_group:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
# Needed for semantic-release to create GitHub releases and publish to npm via OIDC
13+
permissions:
14+
contents: write
15+
issues: write
16+
pull-requests: write
17+
id-token: write
18+
19+
concurrency:
20+
group: Release
21+
cancel-in-progress: false
22+
23+
jobs:
24+
release:
25+
name: Release
26+
environment: Release
27+
# Ensure releases run only when code reaches main via GitHub Merge Queue, or when manually dispatched
28+
runs-on: ubuntu-latest
29+
if: github.repository == 'HarperFast/vite-plugin' || github.repository == 'harperfast/vite-plugin'
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
with:
34+
fetch-depth: 0
35+
- name: Setup Node.js
36+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
37+
with:
38+
node-version-file: '.nvmrc'
39+
cache: npm
40+
registry-url: 'https://registry.npmjs.org'
41+
- name: Install dependencies
42+
run: npm ci
43+
- name: Check format
44+
run: npm run format:check
45+
- name: Run unit tests
46+
run: npm run test:coverage
47+
- name: Semantic Release
48+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'merge_group' && github.event.merge_group.base_ref == 'refs/heads/main') }}
49+
uses: cycjimmy/semantic-release-action@b12c8f6015dc215fe37bc154d4ad456dd3833c90 # v6.0.0
50+
with:
51+
extra_plugins: |
52+
@semantic-release/commit-analyzer
53+
@semantic-release/release-notes-generator
54+
@semantic-release/npm
55+
@semantic-release/git
56+
@semantic-release/github
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
NPM_CONFIG_PROVENANCE: true
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Verify Commits
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, edited, reopened, ready_for_review]
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
commitlint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
15+
with:
16+
fetch-depth: 0
17+
- name: Commitlint
18+
uses: wagoid/commitlint-github-action@b948419dd99f3fd78a6548d48f94e3df7f6bf3ed # v6.2.1
19+
with:
20+
configFile: commitlint.config.cjs

.github/workflows/verify-pr.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Verify PR
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [main]
7+
8+
jobs:
9+
verify:
10+
name: Verify (Node ${{ matrix.node-version }}, ${{ matrix.os }})
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest]
16+
node-version: [20, 22, 24]
17+
defaults:
18+
run:
19+
shell: bash
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23+
- name: Set up Node.js
24+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
cache: npm
28+
- name: Install dependencies
29+
run: npm ci
30+
- name: Check format
31+
run: npm run format:check
32+
- name: Run unit tests
33+
run: npm run test:coverage

.releaserc.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
[
6+
"@semantic-release/release-notes-generator",
7+
{
8+
"preset": "conventionalcommits",
9+
"presetConfig": {
10+
"types": [
11+
{ "type": "feat", "section": "Features" },
12+
{ "type": "feature", "section": "Features" },
13+
{ "type": "docs", "section": "Documentation" },
14+
{ "type": "fix", "section": "Bug Fixes" },
15+
{ "type": "perf", "section": "Performance Improvements" },
16+
{ "type": "refactor", "section": "Code Improvements" },
17+
{ "type": "revert", "section": "Reverts" },
18+
{ "type": "test", "section": "Test Improvements" },
19+
{ "type": "chore", "scope": "deps", "section": "Dependency Updates" }
20+
]
21+
}
22+
}
23+
],
24+
"@semantic-release/npm",
25+
[
26+
"@semantic-release/git",
27+
{
28+
"assets": ["package.json"],
29+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
30+
}
31+
],
32+
"@semantic-release/github"
33+
]
34+
}

commitlint.config.cjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'subject-case': [0, 'never'],
5+
'body-max-line-length': [0, 'never'],
6+
'footer-max-line-length': [0, 'never'],
7+
},
8+
};

example-app/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>Hello Vite</h1>

example-app/vite.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { defineConfig } from 'vite';
2+
export default defineConfig({});

0 commit comments

Comments
 (0)