Add nightly build #409
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: CI | |
| on: | |
| push: | |
| branches: [master, release-*] | |
| tags: | |
| - '[0-9]+.[0-9]+.[0-9]+' | |
| - '[0-9]+.[0-9]+.[0-9]+-*' | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| nightly: | |
| description: 'Build as nightly version' | |
| required: false | |
| type: boolean | |
| default: false | |
| schedule: | |
| - cron: '0 15 * * *' # Run at 3 PM UTC (1 AM Melbourne AEST / 2 AM AEDT) | |
| env: | |
| DOTNET_NOLOGO: true | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4.1.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Show build info | |
| run: | | |
| Write-Host "Building commit: $(git rev-parse HEAD)" | |
| Write-Host "Short hash: $(git rev-parse --short HEAD)" | |
| Write-Host "Git describe: $(git describe --tags)" | |
| Write-Host "Branch: ${{ github.ref_name }}" | |
| Write-Host "Event: ${{ github.event_name }}" | |
| Write-Host "Head ref: ${{ github.head_ref }}" | |
| shell: pwsh | |
| - name: Set version override | |
| run: | | |
| # For PR builds, use the source branch name and ignore height | |
| if ("${{ github.event_name }}" -eq "pull_request" -and "${{ github.head_ref }}" -ne "") { | |
| $branchName = "${{ github.head_ref }}" | |
| Write-Host "PR build from branch: $branchName" | |
| # Sanitize branch name for version (replace invalid chars with dash) | |
| $branchName = $branchName -replace '[/\\]', '-' | |
| $branchName = $branchName -replace '[^a-zA-Z0-9\-]', '' | |
| # Set the pre-release identifier | |
| $preRelease = "octopus-$branchName.${{ github.run_number }}" | |
| Write-Host "Setting MinVerDefaultPreReleaseIdentifiers to: $preRelease" | |
| "MINVERDEFAULTPRERELEASEIDENTIFIERS=$preRelease" >> $env:GITHUB_ENV | |
| # Ignore height - use run number instead | |
| Write-Host "Ignoring git height" | |
| "MINVERIGNOHEIGHT=true" >> $env:GITHUB_ENV | |
| } else { | |
| Write-Host "Not a PR build - using standard MinVer behavior" | |
| } | |
| shell: pwsh | |
| - name: Install .NET SDK | |
| uses: actions/setup-dotnet@v4.0.0 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Build | |
| run: dotnet build LibGit2Sharp.sln --configuration Release | |
| - name: Show version | |
| run: | | |
| $package = Get-ChildItem artifacts/package/*.nupkg | Select-Object -First 1 | |
| Write-Host "Built package: $($package.Name)" | |
| shell: pwsh | |
| - name: Upload packages | |
| uses: actions/upload-artifact@v4.3.1 | |
| with: | |
| name: NuGet packages | |
| path: artifacts/package/ | |
| retention-days: 7 | |
| - name: Verify trimming compatibility | |
| run: dotnet publish TrimmingTestApp | |
| # test: | |
| # name: Test / ${{ matrix.os }} / ${{ matrix.arch }} / ${{ matrix.tfm }} | |
| # runs-on: ${{ matrix.os }} | |
| # strategy: | |
| # matrix: | |
| # arch: [ x64 ] | |
| # os: [ windows-2022, macos-14 ] | |
| # tfm: [ net472, net8.0, net9.0 ] | |
| # exclude: | |
| # - os: macos-14 | |
| # tfm: net472 | |
| # include: | |
| # - arch: arm64 | |
| # os: macos-14 | |
| # tfm: net8.0 | |
| # - arch: arm64 | |
| # os: macos-14 | |
| # tfm: net9.0 | |
| # fail-fast: false | |
| # steps: | |
| # - name: Checkout | |
| # uses: actions/checkout@v4.1.2 | |
| # with: | |
| # fetch-depth: 0 | |
| # - name: Install .NET SDK | |
| # uses: actions/setup-dotnet@v4.0.0 | |
| # with: | |
| # dotnet-version: | | |
| # 9.0.x | |
| # 8.0.x | |
| # - name: Run ${{ matrix.tfm }} tests | |
| # run: dotnet test LibGit2Sharp.sln --configuration Release --framework ${{ matrix.tfm }} --logger "GitHubActions" /p:ExtraDefine=LEAKS_IDENTIFYING | |
| # test-linux: | |
| # name: Test / ${{ matrix.distro }} / ${{ matrix.arch }} / ${{ matrix.tfm }} | |
| # runs-on: ${{ matrix.runnerImage }} | |
| # strategy: | |
| # matrix: | |
| # arch: [ amd64, arm64 ] | |
| # distro: [ alpine.3.17, alpine.3.18, alpine.3.19, alpine.3.20, centos.stream.9, debian.12, fedora.40, ubuntu.20.04, ubuntu.22.04, ubuntu.24.04 ] | |
| # sdk: [ '8.0', '9.0' ] | |
| # exclude: | |
| # - distro: alpine.3.17 | |
| # sdk: '9.0' | |
| # - distro: alpine.3.18 | |
| # sdk: '9.0' | |
| # - distro: alpine.3.19 | |
| # sdk: '9.0' | |
| # include: | |
| # - sdk: '8.0' | |
| # tfm: net8.0 | |
| # - sdk: '9.0' | |
| # tfm: net9.0 | |
| # - arch: amd64 | |
| # runnerImage: ubuntu-22.04 | |
| # - arch: arm64 | |
| # runnerImage: ubuntu-22.04-arm | |
| # fail-fast: false | |
| # steps: | |
| # - name: Checkout | |
| # uses: actions/checkout@v4.1.2 | |
| # with: | |
| # fetch-depth: 0 | |
| # - name: Run ${{ matrix.tfm }} tests | |
| # run: | | |
| # git_command="git config --global --add safe.directory /app" | |
| # test_command="dotnet test LibGit2Sharp.sln --configuration Release -p:TargetFrameworks=${{ matrix.tfm }} --logger "GitHubActions" -p:ExtraDefine=LEAKS_IDENTIFYING" | |
| # docker run -t --rm --platform linux/${{ matrix.arch }} -v "$PWD:/app" -e OPENSSL_ENABLE_SHA1_SIGNATURES=1 gittools/build-images:${{ matrix.distro }}-sdk-${{ matrix.sdk }} sh -c "$git_command && $test_command" | |
| nuget-push: | |
| name: Octopus NuGet Push | |
| needs: [build] # test, test-linux | |
| if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: staging | |
| - name: Push package to feed 🐙 (nightly) | |
| if: github.event_name == 'schedule' || inputs.nightly | |
| id: push-feed-nightly | |
| shell: bash | |
| env: | |
| FEED_API_KEY: ${{ secrets.FEED_API_KEY }} | |
| FEED_SOURCE: ${{ secrets.FEED_SOURCE }} | |
| run: dotnet nuget push staging/**/*.nupkg --api-key "$FEED_API_KEY" --source "$FEED_SOURCE" --skip-duplicate | |
| - name: Push package to feed 🐙 (regular) | |
| if: github.event_name != 'schedule' && !inputs.nightly | |
| id: push-feed-regular | |
| shell: bash | |
| env: | |
| FEED_API_KEY: ${{ secrets.FEED_API_KEY }} | |
| FEED_SOURCE: ${{ secrets.FEED_SOURCE }} | |
| run: dotnet nuget push staging/**/*.nupkg --api-key "$FEED_API_KEY" --source "$FEED_SOURCE" |