Publish #45
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: | |
| workflow_dispatch: | |
| inputs: | |
| run_id: | |
| description: 'CI workflow run ID to publish from' | |
| required: true | |
| confirm: | |
| description: 'Type "publish" to confirm NuGet release' | |
| required: true | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| if: github.event.inputs.confirm == 'publish' | |
| environment: nuget | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Download all packages from CI run | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: packages | |
| pattern: package-* | |
| merge-multiple: true | |
| run-id: ${{ github.event.inputs.run_id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: List packages | |
| run: ls -la packages/ | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '11.0.x' | |
| dotnet-quality: 'preview' | |
| - name: NuGet login (OIDC → temp API key) | |
| id: login | |
| uses: NuGet/login@v1 | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| # Publish RID-specific packages first, then any package, then pointer package last | |
| - name: Publish packages | |
| run: | | |
| # 1. Publish RID-specific AOT packages first | |
| for pkg in packages/dotnet-inspect.win-*.nupkg packages/dotnet-inspect.linux-*.nupkg packages/dotnet-inspect.osx-*.nupkg; do | |
| if [[ -f "$pkg" ]]; then | |
| echo "Publishing $pkg" | |
| dotnet nuget push "$pkg" --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| fi | |
| done | |
| # 2. Publish any (non-AOT) package | |
| for pkg in packages/dotnet-inspect.any.*.nupkg; do | |
| if [[ -f "$pkg" ]]; then | |
| echo "Publishing any package: $pkg" | |
| dotnet nuget push "$pkg" --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| fi | |
| done | |
| # 3. Publish pointer package last (references all RID-specific packages) | |
| for pkg in packages/dotnet-inspect.[0-9]*.nupkg; do | |
| if [[ -f "$pkg" ]]; then | |
| echo "Publishing pointer package: $pkg" | |
| dotnet nuget push "$pkg" --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| fi | |
| done | |
| shell: bash | |
| - name: Get version | |
| id: version | |
| run: | | |
| VERSION=$(grep -oP '(?<=<VersionPrefix>)[^<]+' src/dotnet-inspect/dotnet-inspect.csproj) | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| files: packages/*.nupkg | |
| generate_release_notes: true |