ci: add release pipeline with NuGet packaging and quality gates
Triggered by tag push (v*) or manual dispatch. Validates semver tag format, runs build, test, and format check, then packs NuGet package with version from tag and creates GitHub Release with artifacts attached. Co-Authored-By: Svrnty Inc. <eng@svrnty.com>
This commit is contained in:
parent
1f12cc8c59
commit
16ca6f722b
86
.github/workflows/release.yml
vendored
Normal file
86
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ["v*"]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: "Release tag (e.g. v1.2.0)"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: release-${{ github.ref }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: Validate, Build, Pack & Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Resolve tag
|
||||||
|
id: tag
|
||||||
|
run: |
|
||||||
|
if [[ "${{ github.event_name }}" == "push" ]]; then
|
||||||
|
TAG="${GITHUB_REF_NAME}"
|
||||||
|
else
|
||||||
|
TAG="${{ inputs.tag }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
|
||||||
|
echo "::error::Tag must match semver format (vX.Y.Z[-suffix]): got ${TAG}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ steps.tag.outputs.tag }}
|
||||||
|
|
||||||
|
- uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: "10.0.x"
|
||||||
|
|
||||||
|
- name: Restore
|
||||||
|
run: dotnet restore Svrnty.CQRS.sln
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: dotnet build Svrnty.CQRS.sln --no-restore --configuration Release --warnaserror
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: dotnet test Svrnty.CQRS.sln --no-build --configuration Release --verbosity normal
|
||||||
|
|
||||||
|
- name: Format check
|
||||||
|
run: dotnet format Svrnty.CQRS.sln --verify-no-changes
|
||||||
|
|
||||||
|
- name: Pack NuGet packages
|
||||||
|
run: |
|
||||||
|
dotnet pack Svrnty.CQRS.sln \
|
||||||
|
--no-build \
|
||||||
|
--configuration Release \
|
||||||
|
--output ./artifacts \
|
||||||
|
-p:Version=${{ steps.tag.outputs.version }}
|
||||||
|
|
||||||
|
- name: Upload NuGet artifacts
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: nuget-packages
|
||||||
|
path: ./artifacts/*.nupkg
|
||||||
|
retention-days: 30
|
||||||
|
|
||||||
|
- name: Create GitHub Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.tag.outputs.tag }}
|
||||||
|
generate_release_notes: true
|
||||||
|
files: |
|
||||||
|
artifacts/*.nupkg
|
||||||
|
artifacts/*.snupkg
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
Loading…
Reference in New Issue
Block a user