Skip to content

Commit b1cfd08

Browse files
committed
Publish custom version to custom feed
1 parent cec74ea commit b1cfd08

File tree

3 files changed

+44
-19
lines changed

3 files changed

+44
-19
lines changed

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

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ on:
55
branches:
66
- main
77
- release/*
8-
tags:
9-
- "v*"
10-
pull_request:
11-
branches:
12-
- main
13-
- release/*
14-
types: [ opened, synchronize, reopened ]
158

169
jobs:
1710
# Prime a single LFS cache and expose the exact key for the matrix
@@ -216,7 +209,10 @@ jobs:
216209
path: tests/Images/ActualOutput/
217210

218211
Publish:
219-
needs: [Build]
212+
permissions:
213+
id-token: write # Required for OIDC
214+
contents: read
215+
needs: [ Build ]
220216
runs-on: ubuntu-latest
221217
if: (github.event_name == 'push')
222218
steps:
@@ -235,6 +231,16 @@ jobs:
235231
- name: NuGet Install
236232
uses: NuGet/setup-nuget@v2
237233

234+
- name: Compute Version
235+
id: compute-version
236+
shell: pwsh
237+
run: |
238+
$date = Get-Date -Format "yyyy.M.d"
239+
$buildNumber = "${{ github.run_number }}"
240+
$version = "$date-mc.$buildNumber"
241+
echo "version=$version" >> $env:GITHUB_OUTPUT
242+
echo "Computed version: $version"
243+
238244
- name: NuGet Setup Cache
239245
uses: actions/cache@v5
240246
id: nuget-cache
@@ -245,17 +251,19 @@ jobs:
245251

246252
- name: DotNet Pack
247253
shell: pwsh
248-
run: ./ci-pack.ps1
254+
run: ./ci-pack.ps1 -version "${{ steps.compute-version.outputs.version }}"
249255

250-
- name: Feedz Publish
251-
shell: pwsh
252-
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
256+
- name: Azure Login
257+
uses: azure/login@v2
258+
with:
259+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
260+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
261+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
262+
263+
- name: Install Sleet
264+
run: dotnet tool install -g sleet
255265

256-
- name: NuGet Publish
257-
if: ${{ startsWith(github.ref, 'refs/tags/') }}
266+
- name: Publish Internal
258267
shell: pwsh
259268
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
269+
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)