-
-
Notifications
You must be signed in to change notification settings - Fork 7
204 lines (169 loc) · 6.35 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: Plugin-publish
on: [push, pull_request]
env:
CONFIGURATION: Release
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SDK_VERSION: 8.0
GPG_PRIVATE_KEY: ${{ secrets.ARCHIBOT_GPG_PRIVATE_KEY }} # Optional, if secret not provided, will skip signing SHA512SUMS with GPG key. You can specify your own credentials if you'd like to, simply change ARCHIBOT_GPG_PRIVATE_KEY here to the one you want to use
permissions:
contents: read
jobs:
publish:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
outputs:
PLUGIN_NAME: ${{ steps.plugin-name.outputs.info }}
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
with:
show-progress: false
submodules: recursive
- name: Parse plugin name from Directory.Build.props
id: plugin-name
uses: mavrosxristoforos/get-xml-info@2.0
with:
xml-file: 'Directory.Build.props'
xpath: '//PluginName'
- name: Setup .NET Core
uses: actions/setup-dotnet@v4.1.0
with:
dotnet-version: ${{ env.DOTNET_SDK_VERSION }}
- name: Verify .NET Core
run: dotnet --info
- name: Publish plugin on Unix
if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'ubuntu-')
env:
PLUGIN_NAME: ${{ steps.plugin-name.outputs.info }}
shell: sh
run: |
set -eu
dotnet publish "$PLUGIN_NAME" -c "$CONFIGURATION" -o "out/plugin/${PLUGIN_NAME}" -p:ContinuousIntegrationBuild=true -p:TargetLatestRuntimePatch=false -p:UseAppHost=false --nologo
# By default use fastest compression
seven_zip_args="-mx=1"
zip_args="-1"
# Include extra logic for builds marked for release
case "$GITHUB_REF" in
"refs/tags/"*)
# Tweak compression args for release publishing
seven_zip_args="-mx=9 -mfb=258 -mpass=15"
zip_args="-9"
;;
esac
# Create the final zip file
case "$(uname -s)" in
"Darwin")
# We prefer to use zip on OS X as 7z implementation on that OS doesn't handle file permissions (chmod +x)
if command -v zip >/dev/null; then
(
cd "${GITHUB_WORKSPACE}/out/plugin/${PLUGIN_NAME}"
zip -q -r $zip_args "../../${PLUGIN_NAME}.zip" .
)
else
7z a -bd -slp -tzip -mm=Deflate $seven_zip_args "out/${PLUGIN_NAME}.zip" "${GITHUB_WORKSPACE}/out/plugin/${PLUGIN_NAME}/*"
fi
;;
*)
if command -v 7z >/dev/null; then
7z a -bd -slp -tzip -mm=Deflate $seven_zip_args "out/${PLUGIN_NAME}.zip" "${GITHUB_WORKSPACE}/out/plugin/${PLUGIN_NAME}/*"
else
(
cd "${GITHUB_WORKSPACE}/out/plugin/${PLUGIN_NAME}"
zip -q -r $zip_args "../../${PLUGIN_NAME}.zip" .
)
fi
;;
esac
- name: Publish plugin on Windows
if: startsWith(matrix.os, 'windows-')
env:
PLUGIN_NAME: ${{ steps.plugin-name.outputs.info }}
shell: pwsh
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
Set-Location "$env:GITHUB_WORKSPACE"
dotnet publish "$env:PLUGIN_NAME" -c "$env:CONFIGURATION" -o "out\plugin\$env:PLUGIN_NAME" -p:ContinuousIntegrationBuild=true -p:TargetLatestRuntimePatch=false -p:UseAppHost=false --nologo
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
# By default use fastest compression
$compressionArgs = '-mx=1'
# Include extra logic for builds marked for release
if ($env:GITHUB_REF -like 'refs/tags/*') {
# Tweak compression args for release publishing
$compressionArgs = '-mx=9', '-mfb=258', '-mpass=15'
}
# Create the final zip file
7z a -bd -slp -tzip -mm=Deflate $compressionArgs "out\$env:PLUGIN_NAME.zip" "$env:GITHUB_WORKSPACE\out\plugin\$env:PLUGIN_NAME\*"
if ($LastExitCode -ne 0) {
throw "Last command failed."
}
- name: Upload plugin artifact
uses: actions/upload-artifact@v4.4.3
with:
if-no-files-found: error
name: ${{ matrix.os }}_${{ steps.plugin-name.outputs.info }}
path: out/${{ steps.plugin-name.outputs.info }}.zip
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.2.2
with:
show-progress: false
- name: Download plugin artifact from ubuntu-latest
uses: actions/download-artifact@v4.1.8
with:
name: ubuntu-latest_${{ needs.publish.outputs.PLUGIN_NAME }}
path: out
- name: Import GPG key for signing
uses: crazy-max/ghaction-import-gpg@v6.2.0
if: ${{ env.GPG_PRIVATE_KEY != null }}
with:
gpg_private_key: ${{ env.GPG_PRIVATE_KEY }}
- name: Generate SHA-512 checksums and signature
shell: sh
run: |
set -eu
(
cd "out"
sha512sum *.zip > SHA512SUMS
if [ -n "$GPG_PRIVATE_KEY" ]; then
gpg -a -b -o SHA512SUMS.sign SHA512SUMS
fi
)
- name: Upload SHA512SUMS
uses: actions/upload-artifact@v4.4.3
with:
if-no-files-found: error
name: SHA512SUMS
path: out/SHA512SUMS
- name: Upload SHA512SUMS.sign
uses: actions/upload-artifact@v4.4.3
if: ${{ env.GPG_PRIVATE_KEY != null }}
with:
if-no-files-found: error
name: SHA512SUMS.sign
path: out/SHA512SUMS.sign
- name: Create GitHub release
uses: ncipollo/release-action@v1.14.0
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "out/*"
bodyFile: .github/RELEASE_TEMPLATE.md
makeLatest: false
name: ${{ needs.publish.outputs.PLUGIN_NAME }} V${{ github.ref_name }}
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
updateOnlyUnreleased: true