@@ -12,6 +12,40 @@ permissions:
1212
1313name : main
1414jobs :
15+ version :
16+ name : Set version
17+ runs-on : ubuntu-24.04
18+ outputs :
19+ version : ${{steps.version.outputs.version}}
20+ commit : ${{steps.version.outputs.commit}}
21+ publish : ${{steps.version.outputs.publish}}
22+
23+ steps :
24+ - name : Checkout
25+ uses : actions/checkout@v6
26+ with :
27+ fetch-tags : true
28+ persist-credentials : false
29+
30+ - name : Set version
31+ id : version
32+ run : |
33+ version=$(git describe --exact-match --tags HEAD 2> /dev/null)
34+ publish=false
35+ if [ -z "$version" ]; then
36+ version=$(git log -1 --date=format:"0.%Y.%m%d.%H%M" --format="%ad")
37+ else
38+ publish=true
39+ fi
40+ commit=$(git rev-parse HEAD)
41+
42+ echo "version=$version" >> $GITHUB_OUTPUT
43+ echo "version=$version"
44+ echo "commit=$commit" >> $GITHUB_OUTPUT
45+ echo "commit=$commit"
46+ echo "publish=$publish" >> $GITHUB_OUTPUT
47+ echo "publish=$publish"
48+
1549 linux :
1650 name : Linux (Q8/Q16/Q16-HDRI, x64)
1751 container :
@@ -169,6 +203,8 @@ jobs:
169203 windows :
170204 name : Windows (${{matrix.quantumName}}, ${{matrix.platformName}})
171205 runs-on : windows-2022
206+ needs :
207+ - version
172208
173209 strategy :
174210 fail-fast : false
@@ -193,7 +229,6 @@ jobs:
193229 - name : Checkout
194230 uses : actions/checkout@v6
195231 with :
196- fetch-tags : true
197232 persist-credentials : false
198233
199234 - name : Install dependencies
@@ -220,12 +255,8 @@ jobs:
220255 run : ./build.Magick.NET.cmd ${{ matrix.quantumName }} "${{ matrix.platformName }}" Release
221256 working-directory : build/windows
222257
223- - name : Set NuGet version
224- run : ./set.version.ps1
225- working-directory : publish
226-
227258 - name : Create NuGet package
228- run : ./publish.cmd ${{ matrix.quantumName }} "${{ matrix.platformName }}"
259+ run : ./publish.cmd ${{ matrix.quantumName }} "${{ matrix.platformName }}" "${{ needs.version.outputs.version }}" "${{ needs.version.outputs.commit }}"
229260 working-directory : publish
230261
231262 - name : Upload library
@@ -238,6 +269,8 @@ jobs:
238269 name : Windows (${{matrix.quantumName}}, ${{matrix.platformName}})
239270 # runs-on: windows-11-arm
240271 runs-on : windows-2022
272+ needs :
273+ - version
241274
242275 strategy :
243276 fail-fast : false
@@ -249,7 +282,6 @@ jobs:
249282 - name : Checkout
250283 uses : actions/checkout@v6
251284 with :
252- fetch-tags : true
253285 persist-credentials : false
254286
255287 - name : Install dependencies
@@ -276,12 +308,8 @@ jobs:
276308 run : ./build.Magick.NET.cmd ${{ matrix.quantumName }} "${{ matrix.platformName }}" Release
277309 working-directory : build/windows
278310
279- - name : Set NuGet version
280- run : ./set.version.ps1
281- working-directory : publish
282-
283311 - name : Create NuGet package
284- run : ./publish.cmd ${{ matrix.quantumName }} "${{ matrix.platformName }}"
312+ run : ./publish.cmd ${{ matrix.quantumName }} "${{ matrix.platformName }}" "${{ needs.version.outputs.version }}" "${{ needs.version.outputs.commit }}"
285313 working-directory : publish
286314
287315 - name : Upload library
@@ -293,6 +321,8 @@ jobs:
293321 libraries :
294322 name : Library
295323 runs-on : windows-2022
324+ needs :
325+ - version
296326
297327 strategy :
298328 fail-fast : false
@@ -303,7 +333,6 @@ jobs:
303333 - name : Checkout
304334 uses : actions/checkout@v6
305335 with :
306- fetch-tags : true
307336 persist-credentials : false
308337
309338 - name : Install dependencies
@@ -322,12 +351,8 @@ jobs:
322351 run : ./build.Magick.NET.cmd "Q8" "Any CPU" Release
323352 working-directory : build/windows
324353
325- - name : Set NuGet version
326- run : ./set.version.ps1
327- working-directory : publish
328-
329354 - name : Create NuGet package
330- run : ./publish.library.cmd "Magick.NET.${{ matrix.libraryName }}"
355+ run : ./publish.library.cmd "Magick.NET.${{ matrix.libraryName }}" "${{ needs.version.outputs.version }}" "${{ needs.version.outputs.commit }}"
331356 working-directory : publish
332357
333358 - name : Upload library
0 commit comments