diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9729892..2f047252 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,14 +84,28 @@ jobs: uses: actions/setup-dotnet@v5.2.0 with: dotnet-version: 9.0.x + - name: Compute version suffix for branch builds + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + id: version + run: | + # Sanitize branch name: lowercase, replace non-alphanumeric with hyphen, trim to 20 chars + BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}" + SAFE_BRANCH=$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//' | cut -c1-20) + echo "override=${SAFE_BRANCH}.${{ github.run_number }}" >> "$GITHUB_OUTPUT" - name: Download artifacts uses: actions/download-artifact@v8.0.1 with: path: nuget.package/runtimes/ - name: Create package - run: dotnet pack nuget.package + run: dotnet pack nuget.package ${{ steps.version.outputs.override && format('/p:MinVerDefaultPreReleaseIdentifiers="{0}"', steps.version.outputs.override) || '' }} - name: Upload NuGet package uses: actions/upload-artifact@v7.0.0 with: name: NuGet package path: ./nuget.package/*.nupkg + - name: Push package to feed + shell: bash + env: + FEED_API_KEY: ${{ secrets.FEED_API_KEY }} + FEED_SOURCE: ${{ secrets.FEED_SOURCE }} + run: dotnet nuget push ./nuget.package/*.nupkg --api-key "$FEED_API_KEY" --source "$FEED_SOURCE" diff --git a/README.md b/README.md index a6f68879..e57fd50d 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,26 @@ nuget.exe Pack nuget.package/NativeBinaries.nuspec -Version -NoPackage Where `` is the version from the MinVer tool or manually chosen version. +## Releasing + +Releases are triggered by pushing a git tag. The tag format is: + +``` +-octopus. +``` + +Where `` is the version from the upstream libgit2sharp.nativebinaries repo (e.g., `2.0.312`) and `` is an incrementing number starting at 1. The incrementing number resets to 1 when the upstream version changes. + +For example, for upstream version `2.0.312`: + +``` +git tag 2.0.312-octopus.1 +git push origin 2.0.312-octopus.1 +``` + +This triggers CI, which builds all native binaries, packs the NuGet package with the tag as its version, and pushes it to the configured feed. + + ## Notes on Visual Studio Visual Studio 2019 is required to build the Windows native binaries, however you diff --git a/UpdateLibgit2ToSha.ps1 b/UpdateLibgit2ToSha.ps1 index a3111d3d..151f8e74 100644 --- a/UpdateLibgit2ToSha.ps1 +++ b/UpdateLibgit2ToSha.ps1 @@ -97,7 +97,7 @@ Push-Location $libgit2Directory "@ - Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\LibGit2Sharp.NativeBinaries.props") $buildProperties + Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\Octopus.LibGit2Sharp.NativeBinaries.props") $buildProperties $net46BuildProperties = @" @@ -116,7 +116,7 @@ Push-Location $libgit2Directory "@ - Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\net46\LibGit2Sharp.NativeBinaries.props") $net46BuildProperties + Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\net46\Octopus.LibGit2Sharp.NativeBinaries.props") $net46BuildProperties $dllConfig = @" diff --git a/nuget.package/LibGit2Sharp.NativeBinaries.csproj b/nuget.package/LibGit2Sharp.NativeBinaries.csproj index 5d72ef07..f472fe28 100644 --- a/nuget.package/LibGit2Sharp.NativeBinaries.csproj +++ b/nuget.package/LibGit2Sharp.NativeBinaries.csproj @@ -9,6 +9,7 @@ libgit2\libgit2.license.txt https://github.com/libgit2/libgit2sharp.nativebinaries libgit2\libgit2.png + Octopus.LibGit2Sharp.NativeBinaries Native binaries for LibGit2Sharp true $(MSBuildThisFileDirectory) diff --git a/nuget.package/build/LibGit2Sharp.NativeBinaries.props b/nuget.package/build/Octopus.LibGit2Sharp.NativeBinaries.props similarity index 100% rename from nuget.package/build/LibGit2Sharp.NativeBinaries.props rename to nuget.package/build/Octopus.LibGit2Sharp.NativeBinaries.props diff --git a/nuget.package/build/net46/LibGit2Sharp.NativeBinaries.props b/nuget.package/build/net46/Octopus.LibGit2Sharp.NativeBinaries.props similarity index 100% rename from nuget.package/build/net46/LibGit2Sharp.NativeBinaries.props rename to nuget.package/build/net46/Octopus.LibGit2Sharp.NativeBinaries.props diff --git a/nuget.package/buildMultiTargeting/LibGit2Sharp.NativeBinaries.props b/nuget.package/buildMultiTargeting/LibGit2Sharp.NativeBinaries.props deleted file mode 100644 index 5a6b0742..00000000 --- a/nuget.package/buildMultiTargeting/LibGit2Sharp.NativeBinaries.props +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/nuget.package/buildMultiTargeting/Octopus.LibGit2Sharp.NativeBinaries.props b/nuget.package/buildMultiTargeting/Octopus.LibGit2Sharp.NativeBinaries.props new file mode 100644 index 00000000..844e9946 --- /dev/null +++ b/nuget.package/buildMultiTargeting/Octopus.LibGit2Sharp.NativeBinaries.props @@ -0,0 +1,3 @@ + + + \ No newline at end of file