Skip to content

Commit 8b8cb7a

Browse files
committed
Publish custom version to custom feed
1 parent 357a739 commit 8b8cb7a

File tree

3 files changed

+45
-19
lines changed

3 files changed

+45
-19
lines changed

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

Lines changed: 27 additions & 18 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,7 +210,10 @@ jobs:
216210
path: tests/Images/ActualOutput/
217211

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

246-
- name: DotNet Pack
243+
- name: Compute Version
244+
id: compute-version
247245
shell: pwsh
248-
run: ./ci-pack.ps1
246+
run: |
247+
$date = Get-Date -Format "yyyy.MM.dd"
248+
$buildNumber = "${{ github.run_number }}"
249+
$version = "$date-mc.$buildNumber"
250+
echo "version=$version" >> $env:GITHUB_OUTPUT
251+
echo "Computed version: $version"
249252
250-
- name: Feedz Publish
253+
- name: DotNet Pack
251254
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
255+
run: ./ci-pack.ps1 -version "${{ steps.compute-version.outputs.version }}"
256+
257+
- name: Azure Login
258+
uses: azure/login@v2
259+
with:
260+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
261+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
262+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
263+
264+
- name: Install Sleet
265+
run: dotnet tool install -g sleet
255266

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