Skip to content

Commit 5d37b73

Browse files
committed
ci: add GitHub Actions workflows and commitlint config
- CI workflow for build validation on PRs and main - Commit lint workflow for conventional commit enforcement - Release workflow with changelog generation - Preview changelog workflow for release planning
1 parent fc4389f commit 5d37b73

5 files changed

Lines changed: 273 additions & 0 deletions

File tree

.commitlintrc.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Commitlint configuration for conventional commits
2+
# Based on: https://www.conventionalcommits.org/
3+
4+
extends:
5+
- '@commitlint/config-conventional'
6+
7+
rules:
8+
# Type enum - allowed commit types
9+
type-enum:
10+
- 2 # Level: error
11+
- always
12+
- # Allowed types:
13+
- feat # New feature
14+
- fix # Bug fix
15+
- docs # Documentation only changes
16+
- style # Code style changes (formatting, missing semi-colons, etc)
17+
- refactor # Code refactoring (neither fixes a bug nor adds a feature)
18+
- perf # Performance improvements
19+
- test # Adding or updating tests
20+
- build # Changes to build system or dependencies
21+
- ci # CI/CD configuration changes
22+
- chore # Other changes that don't modify src or test files
23+
- revert # Revert a previous commit
24+
25+
# Type case should be lowercase
26+
type-case:
27+
- 2
28+
- always
29+
- lower-case
30+
31+
# Type must not be empty
32+
type-empty:
33+
- 2
34+
- never
35+
36+
# Scope case should be lowercase
37+
scope-case:
38+
- 2
39+
- always
40+
- lower-case
41+
42+
# Subject must not be empty
43+
subject-empty:
44+
- 2
45+
- never
46+
47+
# Subject must not end with a period
48+
subject-full-stop:
49+
- 2
50+
- never
51+
- '.'
52+
53+
# Disable subject-case to allow uppercase abbreviations (PR, API, CLI, etc.)
54+
subject-case:
55+
- 0
56+
57+
# Header (first line) max length
58+
header-max-length:
59+
- 2
60+
- always
61+
- 72
62+
63+
# Body should have a blank line before it
64+
body-leading-blank:
65+
- 1 # Warning level
66+
- always
67+
68+
# Footer should have a blank line before it
69+
footer-leading-blank:
70+
- 1 # Warning level
71+
- always
72+
73+
# Body max line length
74+
body-max-line-length:
75+
- 1 # Warning level
76+
- always
77+
- 100
78+
79+
# Help URL shown in error messages
80+
helpUrl: 'https://www.conventionalcommits.org/'

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: windows-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup .NET
18+
uses: actions/setup-dotnet@v4
19+
with:
20+
dotnet-version: 8.0.x
21+
22+
- name: Restore dependencies
23+
run: dotnet restore
24+
25+
- name: Build SDK
26+
run: dotnet build src/VsixCommunity.Sdk/VsixCommunity.Sdk.csproj -c Release --no-restore
27+
28+
- name: Build Templates
29+
run: dotnet pack src/VsixCommunity.Sdk.Templates/VsixCommunity.Sdk.Templates.csproj -c Release --no-restore
30+
31+
- name: Build Sample Extension
32+
run: dotnet build samples/SampleExtension/SampleExtension.csproj -c Release
33+
34+
- name: Upload SDK Package
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: sdk-package
38+
path: artifacts/packages/VsixCommunity.Sdk.*.nupkg
39+
40+
- name: Upload Templates Package
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: templates-package
44+
path: artifacts/packages/VsixCommunity.Sdk.Templates.*.nupkg

.github/workflows/commit-lint.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Lint Commit Messages
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, reopened, synchronize]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
11+
jobs:
12+
lint-pr-title:
13+
name: Lint PR Title
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
24+
- name: Install commitlint
25+
run: |
26+
npm install --save-dev @commitlint/cli@18.4.3 @commitlint/config-conventional@18.4.3
27+
28+
- name: Validate PR title
29+
env:
30+
PR_TITLE: ${{ github.event.pull_request.title }}
31+
run: |
32+
echo "Validating PR title: $PR_TITLE"
33+
echo "$PR_TITLE" | npx commitlint --verbose
34+
35+
commitlint:
36+
name: Lint Commit Messages
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0 # Fetch all history for all branches and tags
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: '20'
48+
49+
- name: Install commitlint
50+
run: |
51+
npm install --save-dev @commitlint/cli@18.4.3 @commitlint/config-conventional@18.4.3
52+
53+
- name: Validate PR commits
54+
run: |
55+
# Get the base branch (usually main)
56+
BASE_SHA=$(git merge-base origin/${{ github.base_ref }} HEAD)
57+
58+
# Lint all commits in the PR
59+
npx commitlint --from $BASE_SHA --to HEAD --verbose
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Preview Changelog
2+
3+
run-name: Preview release notes for next release
4+
5+
on:
6+
workflow_dispatch:
7+
8+
jobs:
9+
generate:
10+
name: Generate
11+
uses: CodingWithCalvin/.github/.github/workflows/generate-changelog.yml@main
12+
secrets: inherit
13+
14+
preview:
15+
name: Display Preview
16+
runs-on: ubuntu-latest
17+
needs: generate
18+
19+
steps:
20+
- name: Display changelog preview
21+
run: |
22+
echo "=========================================="
23+
echo "CHANGELOG PREVIEW"
24+
echo "=========================================="
25+
echo ""
26+
echo "${{ needs.generate.outputs.changelog }}"
27+
shell: bash

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to release (e.g., 1.0.0)'
8+
required: true
9+
type: string
10+
publish_sdk:
11+
description: 'Publish SDK package'
12+
required: true
13+
type: boolean
14+
default: true
15+
publish_templates:
16+
description: 'Publish Templates package'
17+
required: true
18+
type: boolean
19+
default: true
20+
21+
jobs:
22+
changelog:
23+
uses: CodingWithCalvin/.github/.github/workflows/generate-changelog.yml@main
24+
25+
release:
26+
needs: changelog
27+
runs-on: windows-latest
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Setup .NET
34+
uses: actions/setup-dotnet@v4
35+
with:
36+
dotnet-version: 8.0.x
37+
38+
- name: Restore dependencies
39+
run: dotnet restore
40+
41+
- name: Build SDK
42+
run: dotnet build src/VsixCommunity.Sdk/VsixCommunity.Sdk.csproj -c Release -p:Version=${{ inputs.version }}
43+
44+
- name: Build Templates
45+
run: dotnet pack src/VsixCommunity.Sdk.Templates/VsixCommunity.Sdk.Templates.csproj -c Release -p:Version=${{ inputs.version }}
46+
47+
- name: Publish SDK to NuGet
48+
if: ${{ inputs.publish_sdk }}
49+
run: dotnet nuget push artifacts/packages/VsixCommunity.Sdk.${{ inputs.version }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
50+
51+
- name: Publish Templates to NuGet
52+
if: ${{ inputs.publish_templates }}
53+
run: dotnet nuget push artifacts/packages/VsixCommunity.Sdk.Templates.${{ inputs.version }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
54+
55+
- name: Create GitHub Release
56+
uses: softprops/action-gh-release@v1
57+
with:
58+
tag_name: v${{ inputs.version }}
59+
name: v${{ inputs.version }}
60+
body: ${{ needs.changelog.outputs.changelog }}
61+
files: |
62+
artifacts/packages/VsixCommunity.Sdk.${{ inputs.version }}.nupkg
63+
artifacts/packages/VsixCommunity.Sdk.Templates.${{ inputs.version }}.nupkg

0 commit comments

Comments
 (0)