Skip to content

Commit 6f9df9a

Browse files
committed
Publish custom version to custom feed
1 parent 1b6108a commit 6f9df9a

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

.github/workflows/build-and-test.yml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@ on:
44
push:
55
branches:
66
- main
7+
- ci
78
- release/*
8-
tags:
9-
- "v*"
10-
pull_request:
11-
branches:
12-
- main
13-
- release/*
14-
types: [ labeled, opened, synchronize, reopened ]
159

1610
jobs:
1711
# Prime a single LFS cache and expose the exact key for the matrix
@@ -216,6 +210,9 @@ jobs:
216210
path: tests/Images/ActualOutput/
217211

218212
Publish:
213+
permissions:
214+
id-token: write # Required for OIDC
215+
contents: read
219216
needs: [Build]
220217
runs-on: ubuntu-latest
221218
if: (github.event_name == 'push')
@@ -243,19 +240,24 @@ jobs:
243240
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
244241
restore-keys: ${{ runner.os }}-nuget-
245242

246-
- name: DotNet Pack
247-
shell: pwsh
248-
run: ./ci-pack.ps1
243+
- name: Install Sleet
244+
run: dotnet tool install -g sleet
249245

250-
- name: Feedz Publish
246+
- name: Compute Version
247+
id: compute-version
251248
shell: pwsh
252249
run: |
253-
dotnet nuget push .\artifacts\*.nupkg -k ${{secrets.FEEDZ_TOKEN}} -s https://f.feedz.io/sixlabors/sixlabors/nuget/index.json --skip-duplicate
254-
dotnet nuget push .\artifacts\*.snupkg -k ${{secrets.FEEDZ_TOKEN}} -s https://f.feedz.io/sixlabors/sixlabors/symbols --skip-duplicate
250+
$date = Get-Date -Format "yyyy.MM.dd"
251+
$buildNumber = "${{ github.run_number }}"
252+
$version = "$date-mc.$buildNumber"
253+
echo "version=$version" >> $env:GITHUB_OUTPUT
254+
echo "Computed version: $version"
255+
256+
- name: DotNet Pack
257+
shell: pwsh
258+
run: ./ci-pack.ps1 -version "${{ steps.compute-version.outputs.version }}"
255259

256-
- name: NuGet Publish
257-
if: ${{ startsWith(github.ref, 'refs/tags/') }}
260+
- name: Publish Internal
258261
shell: pwsh
259262
run: |
260-
dotnet nuget push .\artifacts\*.nupkg -k ${{secrets.NUGET_TOKEN}} -s https://api.nuget.org/v3/index.json --skip-duplicate
261-
dotnet nuget push .\artifacts\*.snupkg -k ${{secrets.NUGET_TOKEN}} -s https://api.nuget.org/v3/index.json --skip-duplicate
263+
sleet push .\artifacts\ --config sleet.json artifacts

ci-pack.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
param(
2+
[Parameter(Mandatory = $true, Position = 0)]
3+
[string]$Version
4+
)
5+
16
dotnet clean -c Release
27

38
$repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY"
49

510
# Building for packing and publishing.
6-
dotnet pack -c Release -p:PackageOutputPath="$PSScriptRoot/artifacts" -p:RepositoryUrl=$repositoryUrl
11+
dotnet pack -c Release -p:PackageOutputPath="$PSScriptRoot/artifacts" -p:RepositoryUrl=$repositoryUrl -p:MinVerVersionOverride=$Version

sleet.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"username": "",
3+
"useremail": "",
4+
"sources": [
5+
{
6+
"name": "ImageSharp",
7+
"type": "azure",
8+
"container": "imagesharp",
9+
"path": "https://mcpublicnugetstouse.blob.core.windows.net/imagesharp/"
10+
}
11+
]
12+
}

0 commit comments

Comments
 (0)