feat: enhance publish workflow with additional platform support and artifact management.

This commit is contained in:
Zhang Dian
2025-06-22 01:15:24 +08:00
parent ef668079b3
commit 7d36352f9c
2 changed files with 236 additions and 139 deletions

View File

@@ -3,110 +3,165 @@ name: Publish Demo
on: on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
platform: win-x64:
description: 'Platform to publish'
required: true
default: 'all'
type: choice
options:
- 'windows'
- 'linux'
- 'android'
- 'all'
win64:
description: 'Windows x64' description: 'Windows x64'
required: true required: true
default: true default: false
type: boolean type: boolean
win64_aot: win-x64-aot:
description: 'Windows x64 AOT' description: 'Windows x64 AOT'
required: true required: true
default: true default: false
type: boolean
linux-x64:
description: 'Linux x64'
required: true
default: false
type: boolean
linux-x64-aot:
description: 'Linux x64 AOT'
required: true
default: false
type: boolean
osx-arm64:
description: 'macOS arm64'
required: true
default: false
type: boolean
osx-arm64-aot:
description: 'macOS arm64 AOT'
required: true
default: false
type: boolean
android-arm64:
description: 'Android arm64'
required: true
default: false
type: boolean type: boolean
jobs: jobs:
windows: win-x64:
if: ${{ github.event.inputs.platform == 'windows' || github.event.inputs.platform == 'all' }} if: ${{ github.event.inputs.win-x64 == 'true' }}
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4.1.1 uses: actions/checkout@v4.2.2
- name: Make upload directory
run: mkdir upload
- name: Publish win-x64 - name: Publish win-x64
if: ${{ github.event.inputs.win64 == 'true' }} run: dotnet publish demo/Ursa.Demo.Desktop -r win-x64 -c Release -o publish --sc -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
run: dotnet publish demo/Ursa.Demo.Desktop -r win-x64 -c Release -o publish/win64 --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true - name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.2
- name: Zip win-x64 with:
if: ${{ github.event.inputs.win64 == 'true' }} name: Ursa.Demo.Desktop.win-x64
run: | path: |
$files = Get-ChildItem -Path publish/win64/* -Recurse -Exclude *.pdb publish
Compress-Archive -Path $files.FullName -DestinationPath upload/Ursa.Demo.Desktop.win-x64.zip !publish/*.pdb
win-x64-aot:
if: ${{ github.event.inputs.win-x64-aot == 'true' }}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Enable Native AOT in .csproj - name: Enable Native AOT in .csproj
if: ${{ github.event.inputs.win64_aot == 'true' }}
run: | run: |
sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
sed -i 's#<!--<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>-->#<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj sed -i 's#<!--<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>-->#<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
- name: Publish win-x64 AOT - name: Publish win-x64 AOT
if: ${{ github.event.inputs.win64_aot == 'true' }} run: dotnet publish demo/Ursa.Demo.Desktop -r win-x64 -c Release -o publish
run: dotnet publish demo/Ursa.Demo.Desktop -r win-x64 -c Release -o publish/win64-aot
- name: Zip win-x64 AOT
if: ${{ github.event.inputs.win64_aot == 'true' }}
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 - name: Upload a Build Artifact
uses: actions/upload-artifact@v4.3.1 uses: actions/upload-artifact@v4.6.2
with: with:
name: windows name: Ursa.Demo.Desktop.win-x64.NativeAOT
path: upload path: |
publish
!publish/*.pdb
linux: linux-x64:
if: ${{ github.event.inputs.platform == 'linux' || github.event.inputs.platform == 'all' }} if: ${{ github.event.inputs.linux-x64 == 'true' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4.1.1 uses: actions/checkout@v4.2.2
- name: Make upload directory
run: mkdir upload
- name: Publish linux-x64 - name: Publish linux-x64
run: dotnet publish demo/Ursa.Demo.Desktop -r linux-x64 -c Release -o publish/linux64 --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true run: dotnet publish demo/Ursa.Demo.Desktop -r linux-x64 -c Release -o publish --sc -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
- name: Zip linux-x64
run: zip -j -r upload/Ursa.Demo.Desktop.linux-x64.zip publish/linux64 -x "*.pdb"
- name: Upload a Build Artifact - name: Upload a Build Artifact
uses: actions/upload-artifact@v4.3.1 uses: actions/upload-artifact@v4.6.2
with: with:
name: linux name: Ursa.Demo.Desktop.linux-x64
path: upload path: |
publish
!publish/*.pdb
android: linux-x64-aot:
if: ${{ github.event.inputs.platform == 'android' || github.event.inputs.platform == 'all' }} if: ${{ github.event.inputs.linux-x64-aot == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Enable Native AOT in .csproj
run: |
sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
sed -i 's#<!--<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>-->#<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
- name: Publish linux-x64 AOT
run: dotnet publish demo/Ursa.Demo.Desktop -r linux-x64 -c Release -o publish
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.2
with:
name: Ursa.Demo.Desktop.linux-x64.NativeAOT
path: |
publish
!publish/*.pdb
osx-arm64:
if: ${{ github.event.inputs.osx-arm64 == 'true' }}
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Publish osx-arm64
run: dotnet publish demo/Ursa.Demo.Desktop -r osx-arm64 -c Release -o publish --sc -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.2
with:
name: Ursa.Demo.Desktop.osx-arm64
path: |
publish
!publish/*.pdb
osx-arm64-aot:
if: ${{ github.event.inputs.osx-arm64-aot == 'true' }}
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Enable Native AOT in .csproj
run: |
sed -i '' 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
sed -i '' 's#<!--<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>-->#<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
- name: Publish osx-arm64 AOT
run: dotnet publish demo/Ursa.Demo.Desktop -r osx-arm64 -c Release -o publish
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.2
with:
name: Ursa.Demo.Desktop.osx-arm64.NativeAOT
path: |
publish
!publish/*.pdb
android-arm64:
if: ${{ github.event.inputs.android-arm64 == 'true' }}
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4.1.1 uses: actions/checkout@v4.2.2
- name: CD Android - name: CD Android
run: cd demo/Ursa.Demo.Android run: cd demo/Ursa.Demo.Android
- name: Restore Dependencies - name: Restore Dependencies
run: dotnet restore run: dotnet restore
- name: Publish Android - name: Publish Android
run: dotnet publish demo/Ursa.Demo.Android -c Release -f net8.0-android --no-restore -o publish -p:RuntimeIdentifier=android-arm64 run: dotnet publish demo/Ursa.Demo.Android -c Release -f net8.0-android --no-restore -o publish -p:RuntimeIdentifier=android-arm64
- name: Upload a Build Artifact - name: Upload a Build Artifact
uses: actions/upload-artifact@v4.3.1 uses: actions/upload-artifact@v4.6.2
with: with:
name: android name: android-arm64
path: publish/*Signed.apk path: publish/*Signed.apk

View File

@@ -7,134 +7,176 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
pack: nuget:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Pack Ursa - name: Pack Ursa
run: dotnet pack src/Ursa -o nugets run: dotnet pack src/Ursa -o nugets
- name: Pack Ursa.Themes.Semi - name: Pack Ursa.Themes.Semi
run: dotnet pack src/Ursa.Themes.Semi -o nugets run: dotnet pack src/Ursa.Themes.Semi -o nugets
- name: Upload a Build Artifact - name: Upload a Build Artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4.6.2
with: with:
name: nugets name: nugets
path: nugets path: nugets
publish-windows: win-x64:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4.2.2
- name: Make upload directory
run: mkdir upload
- name: Publish win-x64 - name: Publish win-x64
run: dotnet publish demo/Ursa.Demo.Desktop -r win-x64 -c Release -o publish/win64 --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true run: dotnet publish demo/Ursa.Demo.Desktop -r win-x64 -c Release -o publish --sc -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
- name: Upload a Build Artifact
- name: Zip win-x64 uses: actions/upload-artifact@v4.6.2
run: | with:
$files = Get-ChildItem -Path publish/win64/* -Recurse -Exclude *.pdb name: Ursa.Demo.Desktop.win-x64
Compress-Archive -Path $files.FullName -DestinationPath upload/Ursa.Demo.Desktop.win-x64.zip path: |
publish
!publish/*.pdb
win-x64-aot:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Enable Native AOT in .csproj - name: Enable Native AOT in .csproj
run: | run: |
sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
sed -i 's#<!--<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>-->#<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj sed -i 's#<!--<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>-->#<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
- name: Publish win-x64 AOT - name: Publish win-x64 AOT
run: dotnet publish demo/Ursa.Demo.Desktop -r win-x64 -c Release -o publish/win64-aot run: dotnet publish demo/Ursa.Demo.Desktop -r win-x64 -c Release -o publish
- 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 - name: Upload a Build Artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4.6.2
with: with:
name: windows name: Ursa.Demo.Desktop.win-x64.NativeAOT
path: upload path: |
publish
!publish/*.pdb
publish-linux: linux-x64:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4.2.2
- name: Make upload directory
run: mkdir upload
- name: Publish linux-x64 - name: Publish linux-x64
run: dotnet publish demo/Ursa.Demo.Desktop -r linux-x64 -c Release -o publish/linux64 --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true run: dotnet publish demo/Ursa.Demo.Desktop -r linux-x64 -c Release -o publish --sc -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
- name: Zip linux-x64
run: zip -j -r upload/Ursa.Demo.Desktop.linux-x64.zip publish/linux64 -x "*.pdb"
- name: Upload a Build Artifact - name: Upload a Build Artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4.6.2
with: with:
name: linux name: Ursa.Demo.Desktop.linux-x64
path: upload path: |
publish
!publish/*.pdb
publish-android: linux-x64-aot:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Enable Native AOT in .csproj
run: |
sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
sed -i 's#<!--<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>-->#<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
- name: Publish linux-x64 AOT
run: dotnet publish demo/Ursa.Demo.Desktop -r linux-x64 -c Release -o publish
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.2
with:
name: Ursa.Demo.Desktop.linux-x64.NativeAOT
path: |
publish
!publish/*.pdb
osx-arm64:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Publish osx-arm64
run: dotnet publish demo/Ursa.Demo.Desktop -r osx-arm64 -c Release -o publish --sc -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.2
with:
name: Ursa.Demo.Desktop.osx-arm64
path: |
publish
!publish/*.pdb
osx-arm64-aot:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Enable Native AOT in .csproj
run: |
sed -i '' 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
sed -i '' 's#<!--<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>-->#<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>#' demo/Ursa.Demo.Desktop/Ursa.Demo.Desktop.csproj
- name: Publish osx-arm64 AOT
run: dotnet publish demo/Ursa.Demo.Desktop -r osx-arm64 -c Release -o publish
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.6.2
with:
name: Ursa.Demo.Desktop.osx-arm64.NativeAOT
path: |
publish
!publish/*.pdb
android-arm64:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4.2.2
- name: CD Android - name: CD Android
run: cd demo/Ursa.Demo.Android run: cd demo/Ursa.Demo.Android
- name: Restore Dependencies - name: Restore Dependencies
run: dotnet restore run: dotnet restore
- name: Publish Android - name: Publish Android
run: dotnet publish demo/Ursa.Demo.Android -c Release -f net8.0-android --no-restore -o publish -p:RuntimeIdentifier=android-arm64 run: dotnet publish demo/Ursa.Demo.Android -c Release -f net8.0-android --no-restore -o publish -p:RuntimeIdentifier=android-arm64
- name: Upload a Build Artifact - name: Upload a Build Artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4.6.2
with: with:
name: android name: android-arm64
path: publish/*Signed.apk path: publish/*Signed.apk
draft-release: draft-release:
needs: [ pack, publish-windows, publish-linux, publish-android ] needs: [
nuget,
win-x64,win-x64-aot,
linux-x64,linux-x64-aot,
osx-arm64,osx-arm64-aot,
android-arm64
]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Download nugets Artifacts - uses: actions/download-artifact@v4.3.0
uses: actions/download-artifact@v4
with:
name: nugets
- name: Download windows Artifacts - name: Display structure of downloaded files
uses: actions/download-artifact@v4 run: ls -R
with:
name: windows
- name: Download linux Artifacts - name: Zip artifacts
uses: actions/download-artifact@v4 run: |
with: zip -rj Ursa.Demo.Desktop.win-x64.zip Ursa.Demo.Desktop.win-x64
name: linux zip -rj Ursa.Demo.Desktop.win-x64.NativeAOT.zip Ursa.Demo.Desktop.win-x64.NativeAOT
zip -rj Ursa.Demo.Desktop.linux-x64.zip Ursa.Demo.Desktop.linux-x64
zip -rj Ursa.Demo.Desktop.linux-x64.NativeAOT.zip Ursa.Demo.Desktop.linux-x64.NativeAOT
zip -rj Ursa.Demo.Desktop.osx-arm64.zip Ursa.Demo.Desktop.osx-arm64
cd Ursa.Demo.Desktop.osx-arm64.NativeAOT
zip -r ../Ursa.Demo.Desktop.osx-arm64.NativeAOT.zip .
- name: Download android Artifacts - name: Display structure of zipped files
uses: actions/download-artifact@v4 run: ls -R
with:
name: android
- name: Release - name: Release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2.3.2
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
with: with:
generate_release_notes: true generate_release_notes: true
draft: true draft: true
files: | files: |
*.nupkg nugets/*.nupkg
android-arm64/*.apk
*.zip *.zip
*.apk