From cbf4bc2514811db3a78a2578fc4bf26bf64da66e Mon Sep 17 00:00:00 2001 From: Vaceslav Ustinov Date: Wed, 1 Apr 2026 17:31:32 +0200 Subject: [PATCH 1/3] 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) --- .github/workflows/publish.yml | 19 +---- .github/workflows/release-please.yml | 92 ++++++++++++++++++++++ .release-please-manifest.json | 3 + TriasDev.Templify/TriasDev.Templify.csproj | 1 - release-please-config.json | 27 +++++++ 5 files changed, 125 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/release-please.yml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8488c46..b5119c5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,8 +1,6 @@ -name: Publish to NuGet +name: Publish to NuGet (Manual) on: - release: - types: [published] workflow_dispatch: inputs: version: @@ -24,22 +22,11 @@ jobs: 8.0.x 9.0.x - - name: Determine version - id: version - run: | - if [[ "${{ github.event_name }}" == "release" ]]; then - VERSION="${{ github.event.release.tag_name }}" - VERSION="${VERSION#v}" # Remove 'v' prefix if present - else - VERSION="${{ github.event.inputs.version }}" - fi - echo "VERSION=$VERSION" >> $GITHUB_OUTPUT - - name: Build run: | dotnet build TriasDev.Templify/TriasDev.Templify.csproj \ --configuration Release \ - -p:Version=${{ steps.version.outputs.VERSION }} + -p:Version=${{ github.event.inputs.version }} - name: Run tests run: | @@ -53,7 +40,7 @@ jobs: dotnet pack TriasDev.Templify/TriasDev.Templify.csproj \ --configuration Release \ --no-build \ - -p:Version=${{ steps.version.outputs.VERSION }} \ + -p:Version=${{ github.event.inputs.version }} \ --output ./artifacts - name: Push to NuGet diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..95e3aa6 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,92 @@ +name: Release + +on: + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + pull-requests: write + +jobs: + release-please: + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + version: ${{ steps.release.outputs.version }} + tag_name: ${{ steps.release.outputs.tag_name }} + + steps: + - id: release + uses: googleapis/release-please-action@v4 + with: + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + + publish: + if: needs.release-please.outputs.release_created == 'true' + needs: release-please + runs-on: ubuntu-latest + + env: + VERSION: ${{ needs.release-please.outputs.version }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 6.0.x + 8.0.x + 9.0.x + + - name: Build + run: | + dotnet build TriasDev.Templify/TriasDev.Templify.csproj \ + --configuration Release \ + -p:Version=${{ env.VERSION }} + + - name: Run tests + run: | + dotnet test TriasDev.Templify.Tests/TriasDev.Templify.Tests.csproj \ + --configuration Release \ + --no-build \ + --verbosity normal + + - name: Pack + run: | + dotnet pack TriasDev.Templify/TriasDev.Templify.csproj \ + --configuration Release \ + --no-build \ + -p:Version=${{ env.VERSION }} \ + --output ./artifacts + + - name: Push to NuGet + run: | + dotnet nuget push ./artifacts/*.nupkg \ + --source https://api.nuget.org/v3/index.json \ + --api-key ${{ secrets.NUGET_API_KEY }} \ + --skip-duplicate + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: nuget-packages + path: ./artifacts/*.nupkg + + - name: Summary + run: | + echo "## NuGet Release" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "| Key | Value |" >> $GITHUB_STEP_SUMMARY + echo "|-----|-------|" >> $GITHUB_STEP_SUMMARY + echo "| **Package** | \`TriasDev.Templify\` |" >> $GITHUB_STEP_SUMMARY + echo "| **Version** | \`${{ env.VERSION }}\` |" >> $GITHUB_STEP_SUMMARY + echo "| **Tag** | \`${{ needs.release-please.outputs.tag_name }}\` |" >> $GITHUB_STEP_SUMMARY diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..0d1bebe --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "1.6.0" +} diff --git a/TriasDev.Templify/TriasDev.Templify.csproj b/TriasDev.Templify/TriasDev.Templify.csproj index c720ada..9524b83 100644 --- a/TriasDev.Templify/TriasDev.Templify.csproj +++ b/TriasDev.Templify/TriasDev.Templify.csproj @@ -23,7 +23,6 @@ word;docx;template;openxml;document-generation;templating;word-documents;office;dotnet;email;text-templates README.md icon.png - 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. diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..e495acd --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,27 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + ".": { + "release-type": "simple", + "component": "templify", + "include-component-in-tag": false, + "changelog-sections": [ + { "type": "feat", "section": "Features" }, + { "type": "fix", "section": "Bug Fixes" }, + { "type": "perf", "section": "Performance Improvements" }, + { "type": "docs", "section": "Documentation", "hidden": true }, + { "type": "chore", "section": "Miscellaneous", "hidden": true }, + { "type": "ci", "section": "CI", "hidden": true }, + { "type": "test", "section": "Tests", "hidden": true }, + { "type": "refactor", "section": "Code Refactoring", "hidden": true } + ], + "extra-files": [ + { + "type": "xml", + "path": "TriasDev.Templify/TriasDev.Templify.csproj", + "xpath": "//Project/PropertyGroup/Version" + } + ] + } + } +} From 2fca89fccab6aae07cf45fd6aca91b43061aa160 Mon Sep 17 00:00:00 2001 From: Vaceslav Ustinov Date: Wed, 1 Apr 2026 17:36:49 +0200 Subject: [PATCH 2/3] 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 --- .github/workflows/publish.yml | 1 + .github/workflows/release-please.yml | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b5119c5..a63a113 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,6 +21,7 @@ jobs: 6.0.x 8.0.x 9.0.x + 10.0.x - name: Build run: | diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 95e3aa6..1aa5470 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,15 +7,17 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: false permissions: - contents: write - pull-requests: write + contents: read jobs: release-please: runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write outputs: release_created: ${{ steps.release.outputs.release_created }} version: ${{ steps.release.outputs.version }} @@ -46,6 +48,7 @@ jobs: 6.0.x 8.0.x 9.0.x + 10.0.x - name: Build run: | From 996cff119327600714a0c7bc4350fb3c88cd6eef Mon Sep 17 00:00:00 2001 From: Vaceslav Ustinov Date: Wed, 1 Apr 2026 17:43:59 +0200 Subject: [PATCH 3/3] ci: normalize version input in manual publish workflow Strip leading 'v' prefix from manual version input to prevent invalid NuGet version errors. --- .github/workflows/publish.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a63a113..489eb43 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,11 +23,18 @@ jobs: 9.0.x 10.0.x + - name: Normalize version + id: version + run: | + VERSION="${{ github.event.inputs.version }}" + VERSION="${VERSION#v}" + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + - name: Build run: | dotnet build TriasDev.Templify/TriasDev.Templify.csproj \ --configuration Release \ - -p:Version=${{ github.event.inputs.version }} + -p:Version=${{ steps.version.outputs.VERSION }} - name: Run tests run: | @@ -41,7 +48,7 @@ jobs: dotnet pack TriasDev.Templify/TriasDev.Templify.csproj \ --configuration Release \ --no-build \ - -p:Version=${{ github.event.inputs.version }} \ + -p:Version=${{ steps.version.outputs.VERSION }} \ --output ./artifacts - name: Push to NuGet