Skip to content

Commit 9a5116b

Browse files
committed
Update ci to publish internal package
1 parent 0774da7 commit 9a5116b

2 files changed

Lines changed: 27 additions & 19 deletions

File tree

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

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

169
jobs:
1710
# Prime a single LFS cache and expose the exact key for the matrix
1811
WarmLFS:
1912
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
2015
outputs:
2116
lfs_key: ${{ steps.expose-key.outputs.lfs_key }}
2217
steps:
@@ -60,6 +55,8 @@ jobs:
6055

6156
Build:
6257
needs: WarmLFS
58+
permissions:
59+
contents: read
6360
strategy:
6461
matrix:
6562
isARM:
@@ -216,6 +213,9 @@ jobs:
216213
flags: unittests
217214

218215
Publish:
216+
permissions:
217+
contents: read
218+
packages: write
219219
needs: [Build]
220220
runs-on: ubuntu-latest
221221
if: (github.event_name == 'push')
@@ -243,19 +243,22 @@ jobs:
243243
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
244244
restore-keys: ${{ runner.os }}-nuget-
245245

246-
- name: DotNet Pack
246+
- name: Compute Version
247+
id: compute-version
247248
shell: pwsh
248-
run: ./ci-pack.ps1
249+
run: |
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"
249255
250-
- name: Feedz Publish
256+
- name: DotNet Pack
251257
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
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+
dotnet nuget push .\artifacts\*.nupkg -k ${{secrets.GITHUB_TOKEN}} -s https://nuget.pkg.github.com/mediaclip/index.json --skip-duplicate
264+
dotnet nuget push .\artifacts\*.snupkg -k ${{secrets.GITHUB_TOKEN}} -s https://nuget.pkg.github.com/mediaclip/index.json --skip-duplicate

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

0 commit comments

Comments
 (0)