Skip to content

Commit c498d1c

Browse files
authored
ci: automate releases with release-please (#89)
* ci: automate releases with release-please (#88) - Add release-please GitHub Action workflow with NuGet publish job - Add release-please config (simple type + XML updater for .csproj) - Simplify publish.yml to manual-only dispatch - Remove PackageReleaseNotes from .csproj (handled by CHANGELOG.md) * ci: address PR review feedback - Add .NET 10 SDK to both workflows - Set cancel-in-progress to false to protect publish jobs - Scope write permissions to release-please job only * ci: normalize version input in manual publish workflow Strip leading 'v' prefix from manual version input to prevent invalid NuGet version errors.
1 parent 71a1fa6 commit c498d1c

5 files changed

Lines changed: 130 additions & 11 deletions

File tree

‎.github/workflows/publish.yml‎

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

33
on:
4-
release:
5-
types: [published]
64
workflow_dispatch:
75
inputs:
86
version:
@@ -23,16 +21,13 @@ jobs:
2321
6.0.x
2422
8.0.x
2523
9.0.x
24+
10.0.x
2625
27-
- name: Determine version
26+
- name: Normalize version
2827
id: version
2928
run: |
30-
if [[ "${{ github.event_name }}" == "release" ]]; then
31-
VERSION="${{ github.event.release.tag_name }}"
32-
VERSION="${VERSION#v}" # Remove 'v' prefix if present
33-
else
34-
VERSION="${{ github.event.inputs.version }}"
35-
fi
29+
VERSION="${{ github.event.inputs.version }}"
30+
VERSION="${VERSION#v}"
3631
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
3732
3833
- name: Build
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: false
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
release-please:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
pull-requests: write
21+
outputs:
22+
release_created: ${{ steps.release.outputs.release_created }}
23+
version: ${{ steps.release.outputs.version }}
24+
tag_name: ${{ steps.release.outputs.tag_name }}
25+
26+
steps:
27+
- id: release
28+
uses: googleapis/release-please-action@v4
29+
with:
30+
config-file: release-please-config.json
31+
manifest-file: .release-please-manifest.json
32+
33+
publish:
34+
if: needs.release-please.outputs.release_created == 'true'
35+
needs: release-please
36+
runs-on: ubuntu-latest
37+
38+
env:
39+
VERSION: ${{ needs.release-please.outputs.version }}
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- name: Setup .NET
45+
uses: actions/setup-dotnet@v4
46+
with:
47+
dotnet-version: |
48+
6.0.x
49+
8.0.x
50+
9.0.x
51+
10.0.x
52+
53+
- name: Build
54+
run: |
55+
dotnet build TriasDev.Templify/TriasDev.Templify.csproj \
56+
--configuration Release \
57+
-p:Version=${{ env.VERSION }}
58+
59+
- name: Run tests
60+
run: |
61+
dotnet test TriasDev.Templify.Tests/TriasDev.Templify.Tests.csproj \
62+
--configuration Release \
63+
--no-build \
64+
--verbosity normal
65+
66+
- name: Pack
67+
run: |
68+
dotnet pack TriasDev.Templify/TriasDev.Templify.csproj \
69+
--configuration Release \
70+
--no-build \
71+
-p:Version=${{ env.VERSION }} \
72+
--output ./artifacts
73+
74+
- name: Push to NuGet
75+
run: |
76+
dotnet nuget push ./artifacts/*.nupkg \
77+
--source https://api.nuget.org/v3/index.json \
78+
--api-key ${{ secrets.NUGET_API_KEY }} \
79+
--skip-duplicate
80+
81+
- name: Upload artifacts
82+
uses: actions/upload-artifact@v4
83+
with:
84+
name: nuget-packages
85+
path: ./artifacts/*.nupkg
86+
87+
- name: Summary
88+
run: |
89+
echo "## NuGet Release" >> $GITHUB_STEP_SUMMARY
90+
echo "" >> $GITHUB_STEP_SUMMARY
91+
echo "| Key | Value |" >> $GITHUB_STEP_SUMMARY
92+
echo "|-----|-------|" >> $GITHUB_STEP_SUMMARY
93+
echo "| **Package** | \`TriasDev.Templify\` |" >> $GITHUB_STEP_SUMMARY
94+
echo "| **Version** | \`${{ env.VERSION }}\` |" >> $GITHUB_STEP_SUMMARY
95+
echo "| **Tag** | \`${{ needs.release-please.outputs.tag_name }}\` |" >> $GITHUB_STEP_SUMMARY

‎.release-please-manifest.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "1.6.0"
3+
}

‎TriasDev.Templify/TriasDev.Templify.csproj‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
<PackageTags>word;docx;template;openxml;document-generation;templating;word-documents;office;dotnet;email;text-templates</PackageTags>
2424
<PackageReadmeFile>README.md</PackageReadmeFile>
2525
<PackageIcon>icon.png</PackageIcon>
26-
<PackageReleaseNotes>v1.6.0: Header and footer support for placeholders, conditionals, and loops. Non-boolean format specifiers (currency, number, string, date). Unified equality operators (== alias for =) with condition validation.</PackageReleaseNotes>
2726
</PropertyGroup>
2827

2928
<ItemGroup>

‎release-please-config.json‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"packages": {
4+
".": {
5+
"release-type": "simple",
6+
"component": "templify",
7+
"include-component-in-tag": false,
8+
"changelog-sections": [
9+
{ "type": "feat", "section": "Features" },
10+
{ "type": "fix", "section": "Bug Fixes" },
11+
{ "type": "perf", "section": "Performance Improvements" },
12+
{ "type": "docs", "section": "Documentation", "hidden": true },
13+
{ "type": "chore", "section": "Miscellaneous", "hidden": true },
14+
{ "type": "ci", "section": "CI", "hidden": true },
15+
{ "type": "test", "section": "Tests", "hidden": true },
16+
{ "type": "refactor", "section": "Code Refactoring", "hidden": true }
17+
],
18+
"extra-files": [
19+
{
20+
"type": "xml",
21+
"path": "TriasDev.Templify/TriasDev.Templify.csproj",
22+
"xpath": "//Project/PropertyGroup/Version"
23+
}
24+
]
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)