Skip to content

Commit 75f4d82

Browse files
committed
chore(ci): add reusable workflows
1 parent 23a51f5 commit 75f4d82

File tree

3 files changed

+96
-4
lines changed

3 files changed

+96
-4
lines changed

.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/[email protected] @commitlint/[email protected]
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/[email protected] @commitlint/[email protected]
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/publish.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ permissions:
88
actions: read
99

1010
jobs:
11+
changelog:
12+
name: Generate Changelog
13+
uses: CodingWithCalvin/.github/.github/workflows/generate-changelog.yml@main
14+
secrets: inherit
15+
1116
publish:
17+
needs: changelog
1218
runs-on: windows-latest
1319
outputs:
1420
version: ${{ steps.artifact_manifest.outputs.version }}
@@ -22,22 +28,22 @@ jobs:
2228
with:
2329
workflow: release_build_and_deploy.yml
2430
workflow_conclusion: success
25-
31+
2632
- name: 2. Parse Artifact Manifest
2733
id: artifact_manifest
2834
uses: ActionsTools/read-json-action@main
2935
with:
3036
file_path: ./artifact/CodingWithCalvin.OpenInNotepadPlusPlus.info
31-
37+
3238
- name: 3. Create Tag & Release
3339
uses: ncipollo/[email protected]
3440
with:
3541
artifacts: ./artifact/CodingWithCalvin.OpenInNotepadPlusPlus.vsix
36-
generateReleaseNotes: true
42+
body: ${{ needs.changelog.outputs.changelog }}
3743
makeLatest: true
3844
commit: ${{ steps.artifact_manifest.outputs.sha }}
3945
tag: ${{ steps.artifact_manifest.outputs.version }}
40-
46+
4147
- name: 4. Publish Release to Marketplace
4248
if: success()
4349
uses: CodingWithCalvin/GHA-VSMarketplacePublisher@v1

0 commit comments

Comments
 (0)