From 448a0d0baf6e63923332cc287ac3eb80becce419 Mon Sep 17 00:00:00 2001 From: Byron Mayne Date: Sun, 5 Jul 2026 23:16:21 -0400 Subject: [PATCH] Changed the ci to create pre-release versions Before it would only create release tags --- .github/workflows/ci.yml | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a8a220..cfad5ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,11 @@ name: Publish on: - push: {} + push: + branches: + - main + tags: + - '*' pull_request: {} - release: - types: [published] env: Configuration: Release @@ -16,8 +18,6 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - name: Setup .NET uses: actions/setup-dotnet@v3 with: @@ -37,8 +37,6 @@ jobs: path: Sandbox/ steps: - uses: actions/checkout@v3 - with: - ref: ${{ github.head_ref }} - name: Setup .NET uses: actions/setup-dotnet@v3 with: @@ -59,10 +57,10 @@ jobs: project: - name: SourceGenerator.Foundations - name: SourceGenerator.Foundations.Contracts + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) steps: - uses: actions/checkout@v3 with: - ref: ${{ github.head_ref }} # checkout the correct branch name fetch-depth: 0 # fetch the whole repo history - name: Setup .NET uses: actions/setup-dotnet@v3 @@ -72,12 +70,21 @@ jobs: run: dotnet tool restore - name: GitVersion run: dotnet gitversion /output buildserver + + - name: Set prerelease package version (main) + if: github.ref == 'refs/heads/main' + run: echo "PACKAGE_VERSION=$env:GitVersion_NuGetVersionV2" >> $env:GITHUB_ENV + + - name: Set release package version (tag) + if: startsWith(github.ref, 'refs/tags/') + run: echo "PACKAGE_VERSION=$env:GitVersion_MajorMinorPatch" >> $env:GITHUB_ENV + # Build - name: Build | ${{ matrix.project.name }} - run: dotnet build src\SourceGenerator.Foundations\SourceGenerator.Foundations.csproj -p:Version=${{env.GitVersion_AssemblySemVer}} -p:PackageVersion=${{env.GitVersion_SemVer}} + run: dotnet build src\SourceGenerator.Foundations\SourceGenerator.Foundations.csproj -p:Version=$env:GitVersion_AssemblySemVer -p:PackageVersion=$env:PACKAGE_VERSION # Pack - name: Pack | ${{ matrix.project.name }} - run: dotnet pack src\${{ matrix.project.name }}\${{ matrix.project.name }}.csproj -p:Version=${{env.GitVersion_AssemblySemVer}} -p:PackageVersion=${{env.GitVersion_FullSemVer}} + run: dotnet pack src\${{ matrix.project.name }}\${{ matrix.project.name }}.csproj -p:Version=$env:GitVersion_AssemblySemVer -p:PackageVersion=$env:PACKAGE_VERSION # Get a short-lived NuGet API key - name: NuGet login (OIDC → temp API key) @@ -88,5 +95,5 @@ jobs: # Release - name: Push | ${{ matrix.project.name }} - if: github.event_name == 'release' + if: github.event_name == 'push' run: dotnet nuget push src\${{ matrix.project.name }}\bin\${{env.Configuration}}\*.nupkg --skip-duplicate --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json