Publish #1014
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish | |
| on: | |
| schedule: | |
| - cron: '40 9 * * *' | |
| workflow_dispatch: | |
| release: | |
| types: [published] | |
| inputs: | |
| is_release_event: | |
| description: Should this be a release or a preview package | |
| required: true | |
| default: 'false' | |
| jobs: | |
| activity-short-circuit: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| same_sha: ${{ steps.check.outputs.same_sha }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get Activity Short Circuit | |
| id: check | |
| run: | | |
| git branch -a | |
| git fetch origin nightly:nightly | |
| head_sha=$(git rev-parse --verify HEAD) | |
| nightly_sha=$(git rev-parse --verify nightly) | |
| if [[ "$head_sha" == "$nightly_sha" ]]; then | |
| same_sha=true; | |
| else | |
| same_sha=false; | |
| fi | |
| echo "head_sha=$head_sha" | |
| echo "nightly_sha=$nightly_sha" | |
| echo "same_sha=${same_sha}" | |
| echo "same_sha=${same_sha}" >> $GITHUB_OUTPUT | |
| build-test: | |
| needs: activity-short-circuit | |
| if: needs.activity-short-circuit.outputs.same_sha == 'false' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v3.0.3 | |
| with: | |
| versionSpec: '6.0.5' | |
| - name: Determine Version | |
| id: version_step # step id used as reference for output values | |
| uses: gittools/actions/gitversion/execute@v3.0.3 | |
| - name: Setup .NET 10 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0.* | |
| - name: Clean dependencies | |
| run: | | |
| dotnet clean Mutagen.Bethesda.Serialization.slnx -c Release | |
| dotnet clean Mutagen.Bethesda.Serialization.Tests.slnx -c Release | |
| dotnet nuget locals all --clear | |
| - name: Build Main Solution | |
| run: dotnet build Mutagen.Bethesda.Serialization.slnx -c Release -p:GitVersion_NuGetVersion=${{ steps.version_step.outputs.fullSemVer }} | |
| - name: Test Main Solution | |
| run: dotnet test Mutagen.Bethesda.Serialization.slnx -c Release --no-build -p:GitVersion_NuGetVersion=${{ steps.version_step.outputs.fullSemVer }} | |
| - name: Add results to local nuget cache | |
| run: | | |
| workingDir="$(cd "$(dirname "./")"; pwd)/$(basename "./")" | |
| echo "workingDir=$workingDir" | |
| dotnet nuget add source "${workingDir}/nupkg" --name SelfNugetPackages | |
| dotnet nuget enable source SelfNugetPackages | |
| - name: Build Test Solution | |
| run: dotnet build Mutagen.Bethesda.Serialization.Tests.slnx -c Release /p:GeneratePackageOnBuild=false -p:GitVersion_NuGetVersion=${{ steps.version_step.outputs.fullSemVer }} | |
| - name: Test Test Solution | |
| run: dotnet test Mutagen.Bethesda.Serialization.Tests.slnx -c Release --no-build -p:GitVersion_NuGetVersion=${{ steps.version_step.outputs.fullSemVer }} | |
| build-test-push: | |
| needs: [build-test, activity-short-circuit] | |
| if: needs.activity-short-circuit.outputs.same_sha == 'false' | |
| runs-on: windows-latest | |
| steps: | |
| - name: Get timestamp | |
| uses: 1466587594/get-current-time@v1 | |
| id: current-time | |
| with: | |
| format: YYYYMMDD-HHmmSS | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v3.0.3 | |
| with: | |
| versionSpec: '6.0.5' | |
| - name: Determine Version | |
| id: version_step # step id used as reference for output values | |
| uses: gittools/actions/gitversion/execute@v3.0.3 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: | | |
| 8.0.* | |
| 9.0.* | |
| 10.0.* | |
| include-prerelease: true | |
| - name: Clean dependencies | |
| run: | | |
| dotnet clean Mutagen.Bethesda.Serialization.slnx -c Release | |
| dotnet nuget locals all --clear | |
| - name: Build Main Solution | |
| run: dotnet build Mutagen.Bethesda.Serialization.slnx -c Release /p:GeneratePackageOnBuild=false -p:GitVersion_NuGetVersion=${{ steps.version_step.outputs.fullSemVer }} | |
| - name: Pack | |
| if: ${{ success() }} | |
| run: dotnet pack Mutagen.Bethesda.Serialization.slnx -c Release --no-build --no-restore -o out -p:GitVersion_NuGetVersion=${{ steps.version_step.outputs.fullSemVer }} | |
| - name: Publish to Github | |
| uses: svenstaro/upload-release-action@v2 | |
| if: ${{ success() && !github.event.release.prerelease && github.event_name == 'release' }} | |
| with: | |
| file: "out/*.nupkg" | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| tag: ${{ github.event.release.tag_name }} | |
| file_glob: "true" | |
| - name: Publish to Nuget.org | |
| run: | | |
| Get-ChildItem "out/*.nupkg" | ForEach-Object { | |
| Write-Host "Pushing $($_.Name)" | |
| dotnet nuget push $_.FullName --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json | |
| } | |
| update-nightly: | |
| needs: [build-test-push, activity-short-circuit] | |
| if: needs.activity-short-circuit.outputs.same_sha == 'false' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Reset nightly to main | |
| run: | | |
| head_sha=$(git rev-parse --verify HEAD) | |
| echo "head_sha=$head_sha" | |
| git checkout nightly | |
| git reset --hard $head_sha | |
| git push |