name: OfficeCom Sentinel Client on: push: branches: - main tags: - "v*" workflow_dispatch: inputs: build_windows: description: "Build the Windows release package" required: false default: "false" jobs: validate-client: runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: "10.0.x" - name: Restore client run: dotnet restore ./src/OCSentinelCli/OCSentinelCli.csproj - name: Build client run: dotnet build ./src/OCSentinelCli/OCSentinelCli.csproj -c Release --no-restore build-client-windows: needs: validate-client if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && inputs.build_windows == 'true') # .NET can publish a self-contained Windows x64 client from Linux. # This keeps releases independent of a Windows Gitea runner. runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: "10.0.x" - name: Build client package shell: pwsh run: | ./build/build-client-package.ps1 - name: Build release manifest for tags if: startsWith(github.ref, 'refs/tags/v') shell: pwsh run: | $tag = "${{ github.ref_name }}" $artifactUrl = "https://gitea.officecom.cloud/officecom/oc-sentinel/releases/download/$tag/OCSentinelClient-win-x64.zip" ./build/build-release-manifest.ps1 -ArtifactUrl $artifactUrl - name: Upload package artifacts uses: actions/upload-artifact@v4 with: name: ocsentinel-client-${{ github.sha }} path: | artifacts/OCSentinelClient-win-x64.zip artifacts/OCSentinelClient-win-x64.zip.sha256 artifacts/version.json if-no-files-found: warn - name: Publish Gitea release assets if: startsWith(github.ref, 'refs/tags/v') shell: pwsh run: | $headers = @{ Authorization = "token $env:GITEA_TOKEN" } $repository = $env:GITEA_REPOSITORY $baseUrl = "$env:GITEA_SERVER_URL/api/v1/repos/$repository" $tag = "${{ github.ref_name }}" $releaseBody = @{ tag_name = $tag target_commitish = "${{ github.sha }}" name = "OfficeCom Sentinel $tag" body = "Automated OfficeCom Sentinel client release." } | ConvertTo-Json try { $release = Invoke-RestMethod -Method Get -Headers $headers -Uri "$baseUrl/releases/tags/$tag" } catch { $release = Invoke-RestMethod -Method Post -Headers $headers -ContentType "application/json" -Body $releaseBody -Uri "$baseUrl/releases" } foreach ($file in @("artifacts/OCSentinelClient-win-x64.zip", "artifacts/OCSentinelClient-win-x64.zip.sha256", "artifacts/version.json")) { $assetName = [System.IO.Path]::GetFileName($file) Invoke-RestMethod -Method Post -Headers $headers -InFile $file -ContentType "application/octet-stream" -Uri "$baseUrl/releases/$($release.id)/assets?name=$assetName" | Out-Null }