Skip to content

Commit 267888d

Browse files
committed
feat(ci): implement automatic release with semantic-release
1 parent d36d847 commit 267888d

4 files changed

Lines changed: 47 additions & 5 deletions

File tree

.github/workflows/nuget-publish.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
name: Publish (Manual)
1+
name: Publish to NuGet
22

33
on:
4-
workflow_dispatch:
4+
workflow_dispatch: # Manual trigger
5+
push:
6+
tags:
7+
- 'v*' # Automatic trigger on version tags (v0.1.0, v1.0.0, etc.)
58

69
env:
710
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
@@ -50,7 +53,8 @@ jobs:
5053
publish:
5154
needs: pack
5255
runs-on: ubuntu-latest
53-
if: github.event_name == 'workflow_dispatch'
56+
# Publish if manually triggered OR if tag was pushed
57+
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
5458
steps:
5559
- name: Download NuGet packages
5660
uses: actions/download-artifact@v4

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write # For creating releases and tags
10+
issues: write # For commenting on issues
11+
pull-requests: write # For commenting on PRs
12+
13+
jobs:
14+
release:
15+
name: Semantic Release
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0 # Fetch all history for semantic-release
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 22
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Release
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
run: npx semantic-release

.releaserc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[
88
"@semantic-release/exec",
99
{
10-
"prepareCmd": "sed -i '' 's|<Version>.*</Version>|<Version>${nextRelease.version}</Version>|' src/Flowrex/Flowrex.csproj"
10+
"prepareCmd": "sed -i 's|<Version>.*</Version>|<Version>${nextRelease.version}</Version>|' src/Flowrex/Flowrex.csproj"
1111
}
1212
],
1313
[

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414
"devDependencies": {
1515
"@commitlint/cli": "^18.4.3",
1616
"@commitlint/config-conventional": "^18.4.3",
17+
"@semantic-release/changelog": "^6.0.3",
18+
"@semantic-release/exec": "^7.1.0",
19+
"@semantic-release/git": "^10.0.1",
1720
"commitizen": "^4.3.0",
1821
"cz-conventional-changelog": "^3.3.0",
19-
"husky": "^8.0.3"
22+
"husky": "^8.0.3",
23+
"semantic-release": "^24.2.9"
2024
},
2125
"config": {
2226
"commitizen": {

0 commit comments

Comments
 (0)