This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
173 lines (137 loc) · 4.79 KB
/
publish.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Madness-publish
on: [push, pull_request]
env:
MADNESS_PRIVATE_SNK: ${{ secrets.MADNESS_PRIVATE_SNK }}
CONFIGURATION: Release
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SDK_VERSION: 8.0
permissions: {}
jobs:
publish:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4.1.1
with:
show-progress: false
- name: Setup .NET Core
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }}
- name: Verify .NET Core
run: dotnet --info
- name: Prepare private key for signing on Unix
if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-')
shell: sh
run: |
set -eu
if [ -n "${MADNESS_PRIVATE_SNK-}" ]; then
echo "$MADNESS_PRIVATE_SNK" | base64 -d > "resources/Madness.snk"
fi
- name: Prepare private key for signing on Windows
if: startsWith(matrix.os, 'windows-')
shell: pwsh
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
if ((Test-Path env:MADNESS_PRIVATE_SNK) -and ($env:MADNESS_PRIVATE_SNK)) {
echo "$env:MADNESS_PRIVATE_SNK" > "resources\Madness.snk"
certutil -f -decode "resources\Madness.snk" "resources\Madness.snk"
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
}
- name: Publish Madness
run: dotnet pack JustArchiNET.Madness -c "${{ env.CONFIGURATION }}" -o "out" -p:ContinuousIntegrationBuild=true --nologo
- name: Rename Madness on Unix
if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-')
shell: sh
run: |
set -eu
mv out/JustArchiNET.Madness.*.nupkg "out/JustArchiNET.Madness.nupkg"
mv out/JustArchiNET.Madness.*.snupkg "out/JustArchiNET.Madness.snupkg"
- name: Rename Madness on Windows
if: startsWith(matrix.os, 'windows-')
shell: pwsh
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Move-Item -Path out\JustArchiNET.Madness.*.nupkg "out\JustArchiNET.Madness.nupkg"
Move-Item -Path out\JustArchiNET.Madness.*.snupkg "out\JustArchiNET.Madness.snupkg"
- name: Upload Madness.nupkg
uses: actions/upload-artifact@v4.3.0
with:
name: ${{ matrix.os }}_Madness.nupkg
path: out/JustArchiNET.Madness.nupkg
- name: Upload Madness.snupkg
uses: actions/upload-artifact@v4.3.0
with:
name: ${{ matrix.os }}_Madness.snupkg
path: out/JustArchiNET.Madness.snupkg
release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: publish
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4.1.1
with:
show-progress: false
- name: Setup .NET Core
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }}
- name: Verify .NET Core
run: dotnet --info
- name: Download Madness.nupkg artifact from windows-latest
uses: actions/download-artifact@v4.1.2
with:
name: windows-latest_Madness.nupkg
path: out
- name: Download Madness.snupkg artifact from windows-latest
uses: actions/download-artifact@v4.1.2
with:
name: windows-latest_Madness.snupkg
path: out
- name: Import GPG key for signing
uses: crazy-max/ghaction-import-gpg@v6.1.0
with:
gpg_private_key: ${{ secrets.ARCHIBOT_GPG_PRIVATE_KEY }}
- name: Generate SHA-512 checksums and signature
shell: sh
run: |
set -eu
(
cd "out"
sha512sum *nupkg > SHA512SUMS
gpg -a -b -o SHA512SUMS.sign SHA512SUMS
)
- name: Upload SHA512SUMS
uses: actions/upload-artifact@v4.3.0
with:
name: SHA512SUMS
path: out/SHA512SUMS
- name: Upload SHA512SUMS.sign
uses: actions/upload-artifact@v4.3.0
with:
name: SHA512SUMS.sign
path: out/SHA512SUMS.sign
- name: Create Madness GitHub release
uses: ncipollo/release-action@v1.13.0
with:
artifacts: "out/*"
bodyFile: .github/RELEASE_TEMPLATE.md
makeLatest: true
name: Madness V${{ github.ref_name }}
token: ${{ secrets.ARCHIBOT_GITHUB_TOKEN }}
- name: Create Madness NuGet release
run: dotnet nuget push "out/JustArchiNET.Madness.nupkg" -k "${{ secrets.MADNESS_NUGET_API_KEY }}" -s "https://api.nuget.org/v3/index.json"