Repository navigation
99 lines (85 loc) · 3.31 KB
/
Copy pathpublish.yml
File metadata and controls
99 lines (85 loc) · 3.31 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Publish
# Triggered by a version tag, e.g. `git tag v1.93.0.1 && git push origin v1.93.0.1`.
# Publishing uses NuGet Trusted Publishing (OIDC): no long-lived API key is
# stored in the repository. Configure the policy on nuget.org under
# Account -> Trusted Publishing with:
# Repository Owner: StArraySharp
# Repository: ImGui4NET
# Workflow File: publish.yml
# Environment: release
on:
push:
tags: ['v*', 'template-v*']
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write # required for the OIDC token exchange
contents: read
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Pack template only
if: startsWith(github.ref, 'refs/tags/template-v')
run: dotnet pack src/ImGui4NET.Template.MultiPlatforms/ImGui4NET.Template.MultiPlatforms.Package.csproj -c Release -o artifacts
- name: Restore tools
if: "!startsWith(github.ref, 'refs/tags/template-v')"
run: dotnet tool restore
- name: Restore
if: "!startsWith(github.ref, 'refs/tags/template-v')"
run: dotnet restore ImGui4NET.slnx
- name: Build
if: "!startsWith(github.ref, 'refs/tags/template-v')"
run: dotnet build ImGui4NET.slnx -c Release --no-restore
- name: Pack
if: "!startsWith(github.ref, 'refs/tags/template-v')"
run: dotnet pack ImGui4NET.slnx -c Release --no-build -o artifacts -p:AlignTemplateVersion=true
# Fails the job when the tag and the packaged version disagree, which is
# the most common way to publish a mislabelled package.
- name: Verify tag matches package version
if: github.ref_type == 'tag'
run: |
tag="${GITHUB_REF_NAME#template-}"
tag="${tag#v}"
package_version="$tag"
# NuGet drops a zero fourth component from the package filename.
if [[ "$tag" =~ ^([0-9]+\.[0-9]+\.[0-9]+)\.0$ ]]; then
package_version="${BASH_REMATCH[1]}"
fi
for f in artifacts/*.nupkg; do
case "$f" in
*".$package_version.nupkg") ;;
*) echo "::error file=$f::package version does not match tag $tag"; exit 1 ;;
esac
done
echo "All packages match tag $tag (NuGet version $package_version)."
- name: NuGet login (OIDC -> temporary API key)
id: login
uses: NuGet/login@v1
with:
user: ${{ secrets.NUGET_USER }}
- name: Push packages
run: |
for f in artifacts/*.nupkg; do
echo "Pushing $f"
dotnet nuget push "$f" \
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
done
- name: Push symbols
if: "!startsWith(github.ref, 'refs/tags/template-v')"
run: |
for f in artifacts/*.snupkg; do
echo "Pushing $f"
dotnet nuget push "$f" \
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
done