diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..58ba88c --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }}