Skip to content

Release v0.1.0

Release v0.1.0 #4

Workflow file for this run

name: Publish
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to pack (e.g. 0.1.0)'
required: false
default: '0.1.0'
jobs:
# Job to verify code quality and correctness before any publishing happens
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Install tools
run: dotnet tool restore
- name: Check formatting
run: dotnet csharpier check .
- name: Run tests
run: dotnet run --project tests/Result.Analyzers.Tests/
# Job to pack and distribute the analyzer
publish:
needs: build-and-test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
# Determine the version string to use for packing
- name: Get version
id: get_version
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
# Strip refs/tags/ and then optionally strip 'v' prefix
VERSION=${GITHUB_REF#refs/tags/}
VERSION=${VERSION#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
else
# Use manual input for dry-runs
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
fi
# Pull structured release notes from Shipped.md for the specific version
- name: Extract Release Notes
id: extract_notes
run: |
VERSION=${{ steps.get_version.outputs.version }}
# 1. Extract curated notes from Shipped.md
CURATED_NOTES=$(sed -n "/## Release $VERSION/,/## Release/p" src/Result.Analyzers/AnalyzerReleases.Shipped.md | grep -v "## Release" | sed '/^$/d')
# 2. Get the last tag for comparison
LAST_TAG=$(git describe --tags --abbrev=0 ${GITHUB_REF}^ 2>/dev/null || echo "")
# 3. Generate commit log
if [ -z "$LAST_TAG" ]; then
COMMIT_LOG=$(git log --pretty=format:"* %s (%h)")
else
COMMIT_LOG=$(git log $LAST_TAG..${GITHUB_REF} --pretty=format:"* %s (%h)")
fi
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "### Rule Updates" >> $GITHUB_OUTPUT
echo "$CURATED_NOTES" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "### Commits" >> $GITHUB_OUTPUT
echo "$COMMIT_LOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Pack
run: dotnet pack src/Result.Analyzers/Result.Analyzers.csproj -c Release -p:PackageVersion=${{ steps.get_version.outputs.version }} -o out
# Only push to NuGet on actual release events
- name: Push to NuGet
if: github.event_name == 'release'
run: dotnet nuget push out/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
# Update the GitHub Release with the package asset and curated notes
- name: GitHub Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v2
with:
files: out/*.nupkg
body: |
${{ steps.extract_notes.outputs.notes }}
---
Full changelog automatically generated by GitHub.
generate_release_notes: true