-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (46 loc) · 1.57 KB
/
pack.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Pack
on:
pull_request:
push:
branches:
- main
tags:
- "*"
jobs:
pack:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
dotnet-version: 8.0.100
- run: echo "${{ secrets.SNK_FILE }}" | base64 --decode > private.snk
- if: ${{ github.event_name == 'pull_request' }}
run: |
.github/scripts/pack.ps1 `
-OutputPath "pack" `
-PullRequestNumber ${{ github.event.pull_request.number }} `
-KeyPath "$pwd/private.snk"
shell: pwsh
- if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
$commitMessage = "$(git log -1 --pretty=%B)"
$pattern = "(?<=Merge pull request #)(\d+)"
if (!($commitMessage -match $pattern)) {
Write-Error "Commit message does not contain a pull request number."
}
Remove-Item -Force -Recurse pack -ErrorAction SilentlyContinue
$commitSHA = "$(git log -1 --pretty=%H)"
.github/scripts/pack.ps1 `
-OutputPath "pack" `
-PullRequestNumber $matches[1] `
-KeyPath "$pwd/private.snk" `
-CommitSHA $commitSHA
Get-ChildItem -Path pack -Filter "*.nupkg" | ForEach-Object {
dotnet nuget push `
$_ `
--skip-duplicate `
--api-key ${{ secrets.NUGET_API_KEY }} `
--source https://api.nuget.org/v3/index.json
}
shell: pwsh