Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 9 additions & 90 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,96 +27,15 @@ jobs:
name: "Test SDK"
uses: "./.github/workflows/test.yml"

pack-job:
name: "Pack"
release-job:
name: "Release"
needs: [test-job]
# NuGet.org packages are permanent, so only release from the main branch
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
version: ${{ steps.set-version.outputs.VERSION }}
steps:

- name: "Clone Git repository"
uses: actions/checkout@v4

- name: "Setup .NET"
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json

- name: "Set version"
id: set-version
shell: bash
env:
VERSION_INPUT: ${{ inputs.version }}
IS_PRERELEASE: ${{ inputs.pre-release }}
run: |
VERSION="$VERSION_INPUT"
if [[ -z "$VERSION" ]]; then
# Date without zero padding so the Git tag matches the version NuGet normalizes to
VERSION="$(date +'%Y.%-m.%-d')"
if [[ "$IS_PRERELEASE" = "true" ]]; then
VERSION="$VERSION-rc"
fi
fi

echo "VERSION=$VERSION"
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"

- name: ".NET pack"
env:
VERSION: ${{ steps.set-version.outputs.VERSION }}
BRANCH: ${{ github.head_ref || github.ref_name }}
run: dotnet pack "./src/cs" --nologo --verbosity minimal --configuration Release -p:PackageVersion="$VERSION" -p:RepositoryBranch="$BRANCH" -p:RepositoryCommit="${{ github.sha }}"

- name: "Upload packages as artifact"
uses: actions/upload-artifact@v4
with:
name: "nupkg"
path: "./nupkg/**/*.nupkg"
if-no-files-found: error

publish-nuget-job:
name: "Publish to NuGet and create GitHub release"
needs: [pack-job]
runs-on: ubuntu-latest
timeout-minutes: 10
uses: "bottlenoselabs/.github/.github/workflows/release-nuget.yml@5ccd4dd015843eb598fa9f6a5ea5703ce974f28b" # main
permissions:
contents: write
id-token: write # Required for NuGet trusted publishing (OIDC)
steps:

- name: "Clone Git repository"
uses: actions/checkout@v4

- name: "Setup .NET"
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json

- name: "Download packages"
uses: actions/download-artifact@v4
with:
name: "nupkg"
path: "./nupkg"

- name: "Login to NuGet (trusted publishing)"
id: nuget-login
uses: NuGet/login@v1
with:
user: ${{ secrets.NUGET_USER }}

- name: "Upload packages to NuGet"
env:
NUGET_API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
run: dotnet nuget push "./nupkg/**/*.nupkg" --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key "$NUGET_API_KEY"

- name: "Create tag and GitHub release"
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
prerelease: ${{ inputs.pre-release }}
tag_name: "v${{ needs.pack-job.outputs.version }}"
target_commitish: ${{ github.sha }}
id-token: write
with:
pre-release: ${{ inputs.pre-release }}
version: ${{ inputs.version }}
secrets:
NUGET_USER: ${{ secrets.NUGET_USER }}
Loading