1313 VERSION_MINOR : 1
1414
1515jobs :
16- version :
16+ build :
1717 runs-on : ubuntu-latest
18- outputs :
19- version : ${{ steps.version.outputs.version }}
20- build : ${{ steps.version.outputs.build }}
21- revision : ${{ steps.version.outputs.revision }}
2218 steps :
2319 - name : checkout
2420 uses : actions/checkout@v3
@@ -41,95 +37,42 @@ jobs:
4137 echo " - Build: ${BUILD_NUMBER}"
4238 echo " - Revision (Run Number): ${REVISION}"
4339
44- build :
45- needs : version
46- strategy :
47- matrix :
48- include :
49- - os : windows-latest
50- platform : windows
51- - os : ubuntu-latest
52- platform : linux
53-
54- runs-on : ${{ matrix.os }}
55-
56- steps :
57- - name : checkout
58- uses : actions/checkout@v5
59- with :
60- fetch-depth : 0
61-
6240 - name : setup .NET
6341 uses : actions/setup-dotnet@v5
6442 with :
6543 dotnet-version : 8.0.x
66-
67- - name : build (Linux)
68- if : runner.os == 'Linux'
69- run : |
70- echo "[+] build linux"
71- dotnet publish -r linux-x64 --self-contained=true -c Release -p:PublishDir=build /p:Version=${{ needs.version.outputs.version }} /p:FileVersion=${{ needs.version.outputs.version }} /p:AssemblyVersion=${{ needs.version.outputs.version }} /p:ProductVersion=${{ needs.version.outputs.version }}
72-
73- - name : build (Windows)
74- if : runner.os == 'Windows'
75- run : |
76- echo "[+] build windows"
77- dotnet publish -r win-x64 --self-contained=true -c Release -p:PublishDir=build /p:Version=${{ needs.version.outputs.version }} /p:FileVersion=${{ needs.version.outputs.version }} /p:AssemblyVersion=${{ needs.version.outputs.version }} /p:ProductVersion=${{ needs.version.outputs.version }}
78-
44+
7945 - name : pack
8046 if : runner.os == 'Linux'
8147 run : |
8248 echo "[+] Packing NuGet package"
83- dotnet pack --configuration Release -o build -p:PublishDir=build /p:Version=${{ needs.version.outputs.version }} /p:FileVersion=${{ needs.version.outputs.version }} /p:AssemblyVersion=${{ needs.version.outputs.version }} /p:ProductVersion=${{ needs.version.outputs.version }}
84-
85- - name : collect artifacts
86- shell : bash
87- run : |
88- mkdir -p artifacts
89- cp build/* artifacts/
90- ls -lh artifacts
91-
92- - name : upload artifacts
93- uses : actions/upload-artifact@v4
94- if : github.event_name == 'push' && github.ref == 'refs/heads/master'
95- with :
96- name : ${{ matrix.platform }}-v${{ needs.version.outputs.version }}
97- path : artifacts/**
98-
99- release :
100- needs : [ version , build ]
101- runs-on : ubuntu-latest
102- if : github.ref == 'refs/heads/master' && github.ref == 'refs/heads/master' && github.event_name == 'push'
103- steps :
104- - name : checkout
105- uses : actions/checkout@v3
106- with :
107- fetch-depth : 0
108-
109- - name : download artifacts
110- uses : actions/download-artifact@v4
111- with :
112- path : artifacts
113- merge-multiple : true
49+ dotnet pack --configuration Release -o artifacts -p:PublishDir=artifacts /p:Version=${{ steps.version.outputs.version }} /p:FileVersion=${{ steps.version.outputs.version }} /p:AssemblyVersion=${{ steps.version.outputs.version }} /p:ProductVersion=${{ steps.version.outputs.version }}
11450
11551 - name : create release
52+ if : github.event_name == 'push' && github.ref == 'refs/heads/master'
53+ continue-on-error : true
11654 uses : softprops/action-gh-release@v1
11755 with :
118- tag_name : v${{ needs .version.outputs.version }}
119- name : release v${{ needs .version.outputs.version }}
56+ tag_name : v${{ steps .version.outputs.version }}
57+ name : release v${{ steps .version.outputs.version }}
12058 generate_release_notes : true
12159 draft : false
12260 prerelease : true
12361 files : artifacts/**
124-
62+
12563 - name : publish to NuGet
64+ if : github.event_name == 'push' && github.ref == 'refs/heads/master'
12665 continue-on-error : true
12766 env :
12867 NUGET_AUTH_TOKEN : ${{ secrets.NUGET_TOKEN }}
12968 run : |
130- echo "[+] Publishing NuGet packages with version ${{ needs.version.outputs.version }}"
131- shopt -s globstar nullglob
69+ if [[ -z "${NUGET_AUTH_TOKEN}" ]]; then
70+ echo "[!] NUGET_TOKEN not exists , skip."; exit 0
71+ fi
13272
73+ echo "[+] Publishing NuGet packages with version ${{ steps.version.outputs.version }}"
74+ shopt -s globstar nullglob
75+
13376 for pkg in artifacts/**/*.nupkg; do
13477 if [[ "$pkg" == *.snupkg ]]; then
13578 continue
13982 --api-key "$NUGET_AUTH_TOKEN" \
14083 --source "https://api.nuget.org/v3/index.json" \
14184 --skip-duplicate
142- done
85+ done
86+
0 commit comments