Merge pull request #11 from unsafePtr/feat/nativeaot #44
Workflow file for this run
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: Build and Publish to NuGet | |
| # Release-only: tags and manual dispatch. Ordinary pushes and PRs are covered by tests.yml and | |
| # aot-tests.yml, which build the same solution across more platforms -- this one used to duplicate | |
| # that on every library change while never packing, since Pack is gated on a version being set. | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Package version (e.g., 1.0.0)' | |
| required: false | |
| type: string | |
| permissions: | |
| id-token: write # required for GitHub OIDC | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04-arm | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Get version from tag | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | |
| - name: Get version from input | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' | |
| run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Restore dependencies | |
| run: dotnet restore src/Base58Encoding.slnx | |
| - name: Build | |
| run: dotnet build src/Base58Encoding.slnx --configuration Release --no-restore | |
| # The release path's own gate. tests.yml never runs on a tag -- a branches: filter does not | |
| # match refs/tags/* -- so for a tag cut anywhere other than an already-tested master commit, | |
| # nothing else has run the suite against this ref. Skipped only for a dispatch with no version, | |
| # which builds without packing. | |
| - name: Test | |
| if: env.VERSION != '' | |
| run: dotnet test --project src/Base58Encoding.Tests/Base58Encoding.Tests.csproj --configuration Release --no-build --verbosity normal | |
| - name: Pack | |
| if: env.VERSION != '' | |
| run: dotnet pack src/Base58Encoding/Base58Encoding.csproj --configuration Release --no-build --output ./artifacts -p:PackageVersion=${{ env.VERSION }} | |
| - name: Upload artifacts | |
| if: env.VERSION != '' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: nupkg | |
| path: ./artifacts/*.nupkg | |
| publish: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| # Only publish on version tags or manual trigger with version | |
| if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && github.event.inputs.version != '') | |
| permissions: | |
| contents: write | |
| id-token: write # enable GitHub OIDC token issuance for this job | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: nupkg | |
| path: ./artifacts | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: NuGet login (OIDC → temp API key) | |
| uses: NuGet/login@v1 | |
| id: login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Publish to NuGet | |
| run: dotnet nuget push ./artifacts/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ steps.login.outputs.NUGET_API_KEY }} --skip-duplicate | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| files: ./artifacts/*.nupkg | |
| generate_release_notes: true |