11name : Build
22
3- on : [push, workflow_dispatch]
3+ on : [push, workflow_dispatch, pull_request ]
44
55env :
66 XMAKE_ROOT : y
77
8+ permissions :
9+ contents : write
10+
811jobs :
912 versioning :
1013 runs-on : ubuntu-latest
1114 outputs :
1215 fullSemVer : ${{ steps.version_step.outputs.fullSemVer }}
1316 semVer : ${{ steps.version_step.outputs.semVer }}
1417 informationalVersion : ${{ steps.version_step.outputs.informationalVersion }}
18+ preReleaseLabel : ${{ steps.version_step.outputs.preReleaseLabel }}
1519 steps :
1620 - name : Checkout repository and submodules
1721 uses : actions/checkout@v4
2731 managed :
2832 needs : versioning
2933 runs-on : ubuntu-latest
34+ permissions :
35+ id-token : write
3036 steps :
3137 - name : Checkout repository and submodules
3238 uses : actions/checkout@v4
@@ -64,27 +70,14 @@ jobs:
6470 uses : xmake-io/github-action-setup-xmake@v1
6571 with :
6672 xmake-version : latest
67- build-cache : true
68- - name : Restore build cache
69- id : restore-cache
70- uses : actions/cache/restore@v4
71- with :
72- path : |
73- build
74- key : ${{ runner.os }}-build
73+ actions-cache-folder : ' .xmake-cache'
74+ actions-cache-key : xmake-${{ runner.os }}
7575 - name : Build
7676 run : |
7777 xmake f --cc=gcc-14 --cxx=g++-14 -y
7878 xmake build -y
7979 env :
8080 SWIFTLY_VERSION : ${{ needs.versioning.outputs.fullSemVer }}
81- - name : Save cache
82- id : save-cache
83- uses : actions/cache/save@v4
84- with :
85- path : |
86- build
87- key : ${{ steps.restore-cache.outputs.cache-primary-key }}
8881 - name : Upload plugin as artifact
8982 uses : actions/upload-artifact@v4
9083 with :
@@ -104,27 +97,12 @@ jobs:
10497 uses : xmake-io/github-action-setup-xmake@v1
10598 with :
10699 xmake-version : latest
107- build-cache : true
108- - name : Restore build cache
109- id : restore-cache
110- uses : actions/cache/restore@v4
111- with :
112- path : |
113- build
114- key : ${{ runner.os }}-build
100+ actions-cache-key : xmake-${{ runner.os }}
115101 - name : Build
116102 run : |
117- xmake f --ccache=y
118103 xmake build -y
119104 env :
120105 SWIFTLY_VERSION : ${{ needs.versioning.outputs.fullSemVer }}
121- - name : Save cache
122- id : save-cache
123- uses : actions/cache/save@v4
124- with :
125- path : |
126- build
127- key : ${{ steps.restore-cache.outputs.cache-primary-key }}
128106 - name : Upload plugin as artifact
129107 uses : actions/upload-artifact@v4
130108 with :
@@ -140,8 +118,8 @@ jobs:
140118 needs : [versioning, linux_core, windows_core, managed]
141119 runs-on : ubuntu-latest
142120 env :
143- LINUX_FOLDER : swiftlys2-linux-${{ needs.versioning.outputs.fullSemVer }}
144- WINDOWS_FOLDER : swiftlys2-windows-${{ needs.versioning.outputs.fullSemVer }}
121+ LINUX_FOLDER : swiftlys2-linux-v ${{ needs.versioning.outputs.fullSemVer }}
122+ WINDOWS_FOLDER : swiftlys2-windows-v ${{ needs.versioning.outputs.fullSemVer }}
145123 steps :
146124 - name : Download artifacts
147125 uses : actions/download-artifact@v4
@@ -157,7 +135,7 @@ jobs:
157135 - name : Download artifacts
158136 uses : actions/download-artifact@v4
159137 with :
160- name : swiftlys2_windows
138+ name : swiftlys2_managed
161139 path : ./managed
162140 - name : Download runtimes
163141 run : |
@@ -185,12 +163,83 @@ jobs:
185163 cp -r linux-runtimes/content/ ${{ env.LINUX_FOLDER }}-with-runtimes/swiftlys2/bin/managed/dotnet
186164 cp -r windows-runtimes/content/ ${{ env.WINDOWS_FOLDER }}-with-runtimes/swiftlys2/bin/managed/dotnet
187165
166+ zip -r ${{ env.LINUX_FOLDER }}-with-runtimes.zip ${{ env.LINUX_FOLDER }}-with-runtimes
167+ zip -r ${{ env.WINDOWS_FOLDER }}-with-runtimes.zip ${{ env.WINDOWS_FOLDER }}-with-runtimes
168+ zip -r ${{ env.LINUX_FOLDER }}.zip ${{ env.LINUX_FOLDER }}
169+ zip -r ${{ env.WINDOWS_FOLDER }}.zip ${{ env.WINDOWS_FOLDER }}
170+
188171 - name : Upload package
189172 uses : actions/upload-artifact@v4
190173 with :
191174 name : swiftlys2-package-${{ needs.versioning.outputs.fullSemVer }}
192175 path : |
193- ${{ env.LINUX_FOLDER }}
194- ${{ env.WINDOWS_FOLDER }}
195- ${{ env.LINUX_FOLDER }}-with-runtimes
196- ${{ env.WINDOWS_FOLDER }}-with-runtimes
176+ ${{ env.LINUX_FOLDER }}.zip
177+ ${{ env.WINDOWS_FOLDER }}.zip
178+ ${{ env.LINUX_FOLDER }}-with-runtimes.zip
179+ ${{ env.WINDOWS_FOLDER }}-with-runtimes.zip
180+
181+ releasing :
182+ if : ${{ github.event_name == 'push' }}
183+ needs : [versioning, packaging]
184+ runs-on : ubuntu-latest
185+ steps :
186+ - name : Checkout repository and submodules
187+ uses : actions/checkout@v4
188+ with :
189+ fetch-depth : 0
190+ - name : Create tag
191+ run : |
192+ TAG_NAME="v${{ needs.versioning.outputs.fullSemVer }}"
193+ MSG="Release v${{ needs.versioning.outputs.fullSemVer }}"
194+
195+ git config --global user.name "github-actions[bot]"
196+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
197+
198+ if git rev-parse -q --verify "refs/tags/$TAG_NAME" >/dev/null; then
199+ echo "Tag $TAG_NAME already exists"; exit 1
200+ fi
201+ git tag -a "$TAG_NAME" -m "${MSG}"
202+ git push origin "$TAG_NAME"
203+
204+ - name : Download artifacts
205+ uses : actions/download-artifact@v4
206+ with :
207+ name : swiftlys2-package-${{ needs.versioning.outputs.fullSemVer }}
208+ path : ./release
209+
210+ - name : Create release
211+ uses : softprops/action-gh-release@v2
212+ with :
213+ generate_release_notes : true
214+ files : |
215+ release/swiftlys2-linux-v${{ needs.versioning.outputs.fullSemVer }}.zip
216+ release/swiftlys2-windows-v${{ needs.versioning.outputs.fullSemVer }}.zip
217+ release/swiftlys2-linux-v${{ needs.versioning.outputs.fullSemVer }}-with-runtimes.zip
218+ release/swiftlys2-windows-v${{ needs.versioning.outputs.fullSemVer }}-with-runtimes.zip
219+ prerelease : ${{ needs.versioning.outputs.preReleaseLabel != '' }}
220+ tag_name : v${{ needs.versioning.outputs.fullSemVer }}
221+ name : Release v${{ needs.versioning.outputs.fullSemVer }}
222+ body : ${{ needs.versioning.outputs.fullSemVer }}
223+ nuget :
224+ if : ${{ github.event_name == 'push' && github.repository_owner == 'swiftly-solution' }}
225+ needs : [versioning, releasing]
226+ runs-on : ubuntu-latest
227+ steps :
228+ - name : Checkout repository and submodules
229+ uses : actions/checkout@v4
230+ with :
231+ fetch-depth : 0
232+ - name : Setup .NET
233+ uses : actions/setup-dotnet@v4
234+ with :
235+ dotnet-version : ' 8.0.x'
236+ - name : Login to NuGet
237+ uses : NuGet/login@v1
238+ id : login
239+ with :
240+ user : samyyc
241+ - name : Publish to nuget
242+ run : |
243+ cd managed
244+ dotnet pack --include-symbols --output nupkgs -c Release -p:Version=${{ needs.versioning.outputs.fullSemVer }}
245+ dotnet nuget push nupkgs/SwiftlyS2.CS2.${{ needs.versioning.outputs.fullSemVer }}.nupkg --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://nuget.org/api/v2/package
0 commit comments