.github/workflows/build.yaml #25
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
| on: workflow_dispatch | |
| jobs: | |
| extract-version: | |
| name: 'Extract version' | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 0 | |
| - name: 'Extract turnierplan.NET version' | |
| id: extract-version | |
| shell: pwsh | |
| run: | | |
| $LatestTag = git describe --tags --abbrev=0 --match=[0-9]*.[0-9]*.[0-9]* | |
| $VersionXmlContent = Get-Content -Path "version.xml" -Raw | |
| $Version = [regex]::Match($VersionXmlContent, '<Version>(\d+\.\d+\.\d+)</Version>').Groups[1].Value | |
| Write-Host "Last git tag: $LatestTag" | |
| Write-Host "Detected version: $Version" | |
| if ($Version -eq $LatestTag) { | |
| Write-Host "Version equals latest tag, failing workflow!" | |
| exit 1 | |
| } | |
| Add-Content -Path $env:GITHUB_OUTPUT -Value "turnierplan_version=$Version" | |
| working-directory: './src' | |
| outputs: | |
| turnierplan_version: ${{ steps.extract-version.outputs.turnierplan_version }} | |
| container-image-amd64: | |
| name: 'Build container image (amd64)' | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| packages: write | |
| needs: | |
| - extract-version | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: 'Replace environment tokens' | |
| uses: cschleiden/replace-tokens@v1 | |
| with: | |
| files: '["**/environment.prod.ts"]' | |
| env: | |
| TOKEN_APPLICATION_VERSION: "${{ needs.extract-version.outputs.turnierplan_version }}" | |
| - name: Login to container registry | |
| uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: 'Build and push container image' | |
| uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | |
| with: | |
| context: . | |
| file: ./docker/turnierplan-amd64/Dockerfile | |
| push: true | |
| # Note: Always push "latest" even when building from a non-main branch. This is because currently, no patches are released for a non-latest minor release. | |
| tags: 'ghcr.io/turnierplan-net/turnierplan:latest,ghcr.io/turnierplan-net/turnierplan:${{ needs.extract-version.outputs.turnierplan_version }}' | |
| nuget-package: | |
| name: 'Build NuGet package' | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - extract-version | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: 'Setup .NET SDK 10.x' | |
| uses: actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version: '10.x' | |
| - name: 'Restore .NET solution' | |
| run: 'dotnet restore' | |
| working-directory: './src' | |
| - name: 'Pack Turnierplan.Adapter' | |
| run: 'dotnet pack Turnierplan.Adapter/Turnierplan.Adapter.csproj -c Release -o .' | |
| working-directory: './src' | |
| - name: 'Push to NuGet' | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| run: 'dotnet nuget push ./*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate' | |
| working-directory: './src' | |
| documentation: | |
| name: 'Build and publish documentation' | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: "Set up Python 3.x" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| - name: "Install requirements" | |
| run: "python3 -m pip install -r requirements.txt" | |
| working-directory: "docs" | |
| - name: "Build documentation" | |
| run: "zensical build --clean" | |
| working-directory: "docs" | |
| - name: "Setup Pages" | |
| uses: actions/configure-pages@v5 | |
| - name: "Upload artifact" | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: "docs/site" | |
| - name: "Deploy to GitHub Pages" | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |