From 612622cf9d1c980ae5abcd2042da8324d19f178c Mon Sep 17 00:00:00 2001
From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com>
Date: Mon, 2 Sep 2024 21:12:08 +0800
Subject: [PATCH] feat: separate pack & publish action.
---
.github/workflows/pack.yml | 34 +-------
.github/workflows/publish.yml | 86 +++++++++++++++++++
.../Ursa.Demo.Desktop.csproj | 8 +-
3 files changed, 93 insertions(+), 35 deletions(-)
create mode 100644 .github/workflows/publish.yml
diff --git a/.github/workflows/pack.yml b/.github/workflows/pack.yml
index 5988927..05b885b 100644
--- a/.github/workflows/pack.yml
+++ b/.github/workflows/pack.yml
@@ -1,4 +1,4 @@
-name: Pack
+name: Pack Nuget
on:
push:
@@ -7,7 +7,7 @@ on:
branches: [ "action/pack" ]
jobs:
- nuget_desktop:
+ nuget:
runs-on: windows-latest
steps:
- name: Checkout
@@ -19,34 +19,8 @@ jobs:
- name: Nuget Ursa.Themes.Semi
run: dotnet pack ./src/Ursa.Themes.Semi -o ./nugets
- - name: Desktop
- run: dotnet publish ./demo/Ursa.Demo.Desktop -r win-x64 -c Release /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true --self-contained true
-
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.3.1
with:
- name: nuget_desktop
- path: |
- ./nugets
- ./**/publish/*.exe
-
- android:
- runs-on: windows-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v4.1.1
-
- - name: CD Android
- run: cd ./demo/Ursa.Demo.Android
-
- - name: Restore Dependencies
- run: dotnet restore
-
- - name: Build
- run: dotnet publish ./demo/Ursa.Demo.Android -c Release -f net8.0-android --no-restore
-
- - name: Upload a Build Artifact
- uses: actions/upload-artifact@v4.3.1
- with:
- name: android
- path: ./**/publish/*Signed.apk
+ name: nugets
+ path: ./nugets
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644
index 0000000..ade8b71
--- /dev/null
+++ b/.github/workflows/publish.yml
@@ -0,0 +1,86 @@
+name: Publish Demo
+
+on:
+ push:
+ branches: [ "action/publish" ]
+ pull_request:
+ branches: [ "action/publish" ]
+
+jobs:
+ windows:
+ runs-on: windows-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4.1.1
+
+ - name: Make upload directory
+ run: mkdir upload
+
+ - name: Publish win-x64
+ run: dotnet publish demo/Ursa.Demo.Desktop -r win-x64 -c Release --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true -o ./publish/win64
+
+ - name: Zip win-x64
+ run: |
+ $files = Get-ChildItem -Path ./publish/win64/* -Recurse -Exclude *.pdb
+ Compress-Archive -Path $files.FullName -DestinationPath ./upload/Ursa.Demo.Desktop.win-x64.zip
+
+ - name: Enable Native AOT in .csproj
+ run: |
+ sed -i 's##true#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
+ sed -i 's##true#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
+
+ - name: Publish win-x64 AOT
+ run: dotnet publish demo/Ursa.Demo.Desktop -r win-x64 -c Release -o ./publish/win64-aot
+
+ - name: Zip win-x64 AOT
+ run: |
+ $files = Get-ChildItem -Path ./publish/win64-aot/* -Recurse -Exclude *.pdb
+ Compress-Archive -Path $files.FullName -DestinationPath ./upload/Ursa.Demo.Desktop.win-x64.NativeAOT.zip
+
+ - name: Upload a Build Artifact
+ uses: actions/upload-artifact@v4.3.1
+ with:
+ name: windows
+ path: ./upload
+
+ linux:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4.1.1
+
+ - name: Make upload directory
+ run: mkdir upload
+
+ - name: Publish linux-x64
+ run: dotnet publish demo/Ursa.Demo.Desktop -r linux-x64 -c Release --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true -o ./publish/linux64
+
+ - name: Zip linux-x64
+ run: zip -j -r ./upload/Ursa.Demo.Desktop.linux-x64.zip ./publish/linux64 -x "*.pdb"
+
+ - name: Upload a Build Artifact
+ uses: actions/upload-artifact@v4.3.1
+ with:
+ name: linux
+ path: ./upload
+
+ android:
+ runs-on: windows-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4.1.1
+
+ - name: CD Android
+ run: cd ./demo/Ursa.Demo.Android
+
+ - name: Restore Dependencies
+ run: dotnet restore
+
+ - name: Publish Android
+ run: dotnet publish demo/Ursa.Demo.Android -c Release -f net8.0-android --no-restore -o ./publish
+
+ - name: Upload a Build Artifact
+ uses: actions/upload-artifact@v4.3.1
+ with:
+ name: android
+ path: ./publish/*Signed.apk
diff --git a/demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj b/demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
index 588bc81..cf622f4 100644
--- a/demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
+++ b/demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
@@ -2,16 +2,14 @@
WinExe
+ One for Windows with net8.0-windows TFM, one for MacOS with net8.0-macos and one with net8.0 TFM for Linux.-->
net8.0
enable
true
true
-
+
+