Skip to content

Commit 9d45b66

Browse files
authored
Add Octopus prefix to package and push to feed (#7)
1 parent 21654fa commit 9d45b66

9 files changed

Lines changed: 41 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,31 @@ jobs:
8484
uses: actions/setup-dotnet@v5.2.0
8585
with:
8686
dotnet-version: 9.0.x
87+
- name: Compute version suffix for branch builds
88+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
89+
id: version
90+
run: |
91+
# Sanitize branch name: lowercase, replace non-alphanumeric with hyphen, trim to 20 chars
92+
BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}"
93+
SAFE_BRANCH=$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//' | cut -c1-20)
94+
echo "override=${SAFE_BRANCH}.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
8795
- name: Download artifacts
8896
uses: actions/download-artifact@v8.0.1
8997
with:
9098
path: nuget.package/runtimes/
9199
- name: Create package
92-
run: dotnet pack nuget.package
100+
run: dotnet pack nuget.package ${{ steps.version.outputs.override && format('/p:MinVerDefaultPreReleaseIdentifiers="{0}"', steps.version.outputs.override) || '' }}
93101
- name: Upload NuGet package
94102
uses: actions/upload-artifact@v7.0.0
95103
with:
96104
name: NuGet package
97105
path: ./nuget.package/*.nupkg
106+
- name: Push package to feed
107+
shell: bash
108+
env:
109+
FEED_API_KEY: ${{ secrets.FEED_API_KEY }}
110+
FEED_SOURCE: ${{ secrets.FEED_SOURCE }}
111+
run: dotnet nuget push ./nuget.package/*.nupkg --api-key "$FEED_API_KEY" --source "$FEED_SOURCE"
98112
ci:
99113
name: ci
100114
needs: [build, package]

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,26 @@ nuget.exe Pack nuget.package/NativeBinaries.nuspec -Version <version> -NoPackage
100100
Where `<version>` is the version from the MinVer tool or manually chosen version.
101101

102102

103+
## Releasing
104+
105+
Releases are triggered by pushing a git tag. The tag format is:
106+
107+
```
108+
<upstream-version>-octopus.<n>
109+
```
110+
111+
Where `<upstream-version>` is the version from the upstream libgit2sharp.nativebinaries repo (e.g., `2.0.312`) and `<n>` is an incrementing number starting at 1. The incrementing number resets to 1 when the upstream version changes.
112+
113+
For example, for upstream version `2.0.312`:
114+
115+
```
116+
git tag 2.0.312-octopus.1
117+
git push origin 2.0.312-octopus.1
118+
```
119+
120+
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.
121+
122+
103123
## Notes on Visual Studio
104124

105125
Visual Studio 2019 is required to build the Windows native binaries, however you

UpdateLibgit2ToSha.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Push-Location $libgit2Directory
9797
</Project>
9898
"@
9999

100-
Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\LibGit2Sharp.NativeBinaries.props") $buildProperties
100+
Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\Octopus.LibGit2Sharp.NativeBinaries.props") $buildProperties
101101

102102
$net46BuildProperties = @"
103103
<Project>
@@ -116,7 +116,7 @@ Push-Location $libgit2Directory
116116
</Project>
117117
"@
118118

119-
Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\net46\LibGit2Sharp.NativeBinaries.props") $net46BuildProperties
119+
Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\net46\Octopus.LibGit2Sharp.NativeBinaries.props") $net46BuildProperties
120120

121121
$dllConfig = @"
122122
<configuration>

nuget.package/LibGit2Sharp.NativeBinaries.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageLicenseFile>libgit2\libgit2.license.txt</PackageLicenseFile>
1010
<PackageProjectUrl>https://github.com/libgit2/libgit2sharp.nativebinaries</PackageProjectUrl>
1111
<PackageIcon>libgit2\libgit2.png</PackageIcon>
12+
<PackageId>Octopus.LibGit2Sharp.NativeBinaries</PackageId>
1213
<Description>Native binaries for LibGit2Sharp</Description>
1314
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1415
<PackageOutputPath>$(MSBuildThisFileDirectory)</PackageOutputPath>

nuget.package/build/LibGit2Sharp.NativeBinaries.props renamed to nuget.package/build/Octopus.LibGit2Sharp.NativeBinaries.props

File renamed without changes.

nuget.package/build/net46/LibGit2Sharp.NativeBinaries.props renamed to nuget.package/build/net46/Octopus.LibGit2Sharp.NativeBinaries.props

File renamed without changes.

nuget.package/buildMultiTargeting/LibGit2Sharp.NativeBinaries.props

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<Import Project="$(MSBuildThisFileDirectory)\..\build\Octopus.LibGit2Sharp.NativeBinaries.props" />
3+
</Project>
242 KB
Binary file not shown.

0 commit comments

Comments
 (0)