Skip to content

Commit 339458d

Browse files
committed
Configure to publish to internal packages
1 parent fd8f253 commit 339458d

File tree

3 files changed

+49
-20
lines changed

3 files changed

+49
-20
lines changed

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

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ on:
44
push:
55
branches:
66
- main
7-
tags:
8-
- "v*"
9-
pull_request:
10-
branches:
11-
- main
12-
- release/*
13-
types: [ labeled, opened, synchronize, reopened ]
7+
- ci
148
jobs:
159
# Prime a single LFS cache and expose the exact key for the matrix
1610
WarmLFS:
1711
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
1814
outputs:
1915
lfs_key: ${{ steps.expose-key.outputs.lfs_key }}
2016
steps:
@@ -55,9 +51,11 @@ jobs:
5551
- name: Git Pull LFS
5652
shell: bash
5753
run: git lfs pull
58-
54+
5955
Build:
6056
needs: WarmLFS
57+
permissions:
58+
contents: read
6159
strategy:
6260
matrix:
6361
isARM:
@@ -210,6 +208,9 @@ jobs:
210208

211209

212210
Publish:
211+
permissions:
212+
id-token: write # Required for OIDC
213+
contents: read
213214
needs: [Build]
214215

215216
runs-on: ubuntu-latest
@@ -240,20 +241,31 @@ jobs:
240241
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
241242
restore-keys: ${{ runner.os }}-nuget-
242243

243-
- name: DotNet Pack
244+
- name: Compute Version
245+
id: compute-version
244246
shell: pwsh
245-
run: ./ci-pack.ps1
247+
run: |
248+
$date = Get-Date -Format "yyyy.MM.dd"
249+
$buildNumber = "${{ github.run_number }}"
250+
$version = "$date-mc.$buildNumber"
251+
echo "version=$version" >> $env:GITHUB_OUTPUT
252+
echo "Computed version: $version"
246253
247-
- name: Feedz Publish
254+
- name: DotNet Pack
248255
shell: pwsh
249-
run: |
250-
dotnet nuget push .\artifacts\*.nupkg -k ${{secrets.FEEDZ_TOKEN}} -s https://f.feedz.io/sixlabors/sixlabors/nuget/index.json --skip-duplicate
251-
dotnet nuget push .\artifacts\*.snupkg -k ${{secrets.FEEDZ_TOKEN}} -s https://f.feedz.io/sixlabors/sixlabors/symbols --skip-duplicate
256+
run: ./ci-pack.ps1 -version "${{ steps.compute-version.outputs.version }}"
257+
258+
- name: Azure Login
259+
uses: azure/login@v2
260+
with:
261+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
262+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
263+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
252264

253-
- name: NuGet Publish
254-
if: ${{ startsWith(github.ref, 'refs/tags/') }}
265+
- name: Install Sleet
266+
run: dotnet tool install -g sleet
267+
268+
- name: Publish Internal
255269
shell: pwsh
256270
run: |
257-
dotnet nuget push .\artifacts\*.nupkg -k ${{secrets.NUGET_TOKEN}} -s https://api.nuget.org/v3/index.json --skip-duplicate
258-
dotnet nuget push .\artifacts\*.snupkg -k ${{secrets.NUGET_TOKEN}} -s https://api.nuget.org/v3/index.json --skip-duplicate
259-
271+
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 --output "$PSScriptRoot/artifacts" /p:RepositoryUrl=$repositoryUrl
11+
dotnet pack -c Release --output "$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)