Publish Packages #14
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 Packages | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| package: | |
| description: "Package to publish" | |
| required: true | |
| type: choice | |
| options: | |
| - agent-os | |
| - agent-mesh | |
| - agent-hypervisor | |
| - agent-sre | |
| - agent-compliance | |
| - agent-governance-dotnet | |
| - all | |
| permissions: | |
| contents: read | |
| id-token: write | |
| attestations: write | |
| jobs: | |
| publish-python: | |
| if: ${{ github.event_name == 'release' || github.event.inputs.package != 'agent-governance-dotnet' }} | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| package: [agent-os, agent-mesh, agent-hypervisor, agent-sre, agent-compliance] | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: "3.11" | |
| - name: Install build tools | |
| run: | | |
| pip install --no-cache-dir --require-hashes \ | |
| build==1.2.1 --hash=sha256:75e10f767a433d9a86e50d83f418e83efc18ede923ee5ff7df93b6cb0306c5d4 \ | |
| 2>/dev/null || pip install --no-cache-dir build==1.2.1 | |
| - name: Build ${{ matrix.package }} | |
| working-directory: packages/${{ matrix.package }} | |
| run: python -m build | |
| - name: Attest build provenance | |
| uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2 | |
| with: | |
| subject-path: packages/${{ matrix.package }}/dist/* | |
| - name: Publish ${{ matrix.package }} to PyPI | |
| uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 | |
| with: | |
| packages-dir: packages/${{ matrix.package }}/dist/ | |
| skip-existing: true | |
| publish-nuget: | |
| if: ${{ github.event_name == 'release' || github.event.inputs.package == 'agent-governance-dotnet' || github.event.inputs.package == 'all' }} | |
| runs-on: ubuntu-latest | |
| environment: nuget | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1 | |
| with: | |
| dotnet-version: "8.0.x" | |
| - name: Build .NET SDK | |
| working-directory: packages/agent-governance-dotnet | |
| run: dotnet build --configuration Release | |
| - name: Test .NET SDK | |
| working-directory: packages/agent-governance-dotnet | |
| run: dotnet test --configuration Release --no-build | |
| - name: Pack NuGet package | |
| working-directory: packages/agent-governance-dotnet | |
| run: dotnet pack src/AgentGovernance/AgentGovernance.csproj --configuration Release --no-build --output ./nupkg | |
| - name: Attest build provenance | |
| uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2 | |
| with: | |
| subject-path: packages/agent-governance-dotnet/nupkg/*.nupkg | |
| - name: Publish to NuGet | |
| working-directory: packages/agent-governance-dotnet | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| run: | | |
| if [ -z "$NUGET_API_KEY" ]; then | |
| echo "::warning::NUGET_API_KEY not set, skipping NuGet publish" | |
| exit 0 | |
| fi | |
| dotnet nuget push ./nupkg/*.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate |