Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and Publish

on:
push:
branches: [master]
tags: ['v*']
pull_request:
branches: [master]

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.x'

- name: Determine version
id: version
shell: pwsh
run: |
if ($env:GITHUB_REF -like 'refs/tags/v*') {
$version = $env:GITHUB_REF -replace 'refs/tags/v', ''
} else {
$version = "0.0.0-ci.${{ github.run_number }}"
}
echo "PackageVersion=$version" >> $env:GITHUB_ENV
Write-Host "Version: $version"

- name: Restore
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore -p:PackageVersion=${{ env.PackageVersion }}

- name: Test
run: dotnet test tests/CodeStructure.Analyzers.Tests/CodeStructure.Analyzers.Tests.csproj --configuration Release --no-build

- name: Pack
run: dotnet pack CodeStructure.Analyzers/CodeStructure.Analyzers.csproj --configuration Release --no-build --output ./nupkg -p:PackageVersion=${{ env.PackageVersion }}

- name: Push to NuGet
if: startsWith(github.ref, 'refs/tags/v')
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.CodeStructureNuGetKey }} --source https://api.nuget.org/v3/index.json --skip-duplicate
Loading