mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 11:39:48 +00:00
Refactored update platform determination
This commit is contained in:
parent
e1cede1972
commit
37ece2b4ad
99
.github/workflows/build-and-release.yml
vendored
99
.github/workflows/build-and-release.yml
vendored
@ -16,35 +16,30 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- platform: 'macos-latest' # for ARM-based macOS (M1 and above)
|
- platform: 'macos-latest' # for ARM-based macOS (M1 and above)
|
||||||
rust_target: 'aarch64-apple-darwin'
|
rust_target: 'aarch64-apple-darwin'
|
||||||
update_platform: 'darwin-aarch64'
|
|
||||||
dotnet_runtime: 'osx-arm64'
|
dotnet_runtime: 'osx-arm64'
|
||||||
dotnet_name_postfix: '-aarch64-apple-darwin'
|
dotnet_name_postfix: '-aarch64-apple-darwin'
|
||||||
tauri_bundle: 'dmg updater'
|
tauri_bundle: 'dmg updater'
|
||||||
|
|
||||||
- platform: 'macos-latest' # for Intel-based macOS
|
- platform: 'macos-latest' # for Intel-based macOS
|
||||||
rust_target: 'x86_64-apple-darwin'
|
rust_target: 'x86_64-apple-darwin'
|
||||||
update_platform: 'darwin-x86_64'
|
|
||||||
dotnet_runtime: 'osx-x64'
|
dotnet_runtime: 'osx-x64'
|
||||||
dotnet_name_postfix: '-x86_64-apple-darwin'
|
dotnet_name_postfix: '-x86_64-apple-darwin'
|
||||||
tauri_bundle: 'dmg updater'
|
tauri_bundle: 'dmg updater'
|
||||||
|
|
||||||
- platform: 'ubuntu-22.04' # for x86-based Linux
|
- platform: 'ubuntu-22.04' # for x86-based Linux
|
||||||
rust_target: 'x86_64-unknown-linux-gnu'
|
rust_target: 'x86_64-unknown-linux-gnu'
|
||||||
update_platform: 'linux-x86_64'
|
|
||||||
dotnet_runtime: 'linux-x64'
|
dotnet_runtime: 'linux-x64'
|
||||||
dotnet_name_postfix: '-x86_64-unknown-linux-gnu'
|
dotnet_name_postfix: '-x86_64-unknown-linux-gnu'
|
||||||
tauri_bundle: 'appimage deb updater'
|
tauri_bundle: 'appimage deb updater'
|
||||||
|
|
||||||
- platform: 'windows-latest' # for x86-based Windows
|
- platform: 'windows-latest' # for x86-based Windows
|
||||||
rust_target: 'x86_64-pc-windows-msvc'
|
rust_target: 'x86_64-pc-windows-msvc'
|
||||||
update_platform: 'windows-x86_64'
|
|
||||||
dotnet_runtime: 'win-x64'
|
dotnet_runtime: 'win-x64'
|
||||||
dotnet_name_postfix: '-x86_64-pc-windows-msvc.exe'
|
dotnet_name_postfix: '-x86_64-pc-windows-msvc.exe'
|
||||||
tauri_bundle: 'nsis updater'
|
tauri_bundle: 'nsis updater'
|
||||||
|
|
||||||
- platform: 'windows-latest' # for ARM-based Windows
|
- platform: 'windows-latest' # for ARM-based Windows
|
||||||
rust_target: 'aarch64-pc-windows-msvc'
|
rust_target: 'aarch64-pc-windows-msvc'
|
||||||
update_platform: 'windows-aarch64'
|
|
||||||
dotnet_runtime: 'win-arm64'
|
dotnet_runtime: 'win-arm64'
|
||||||
dotnet_name_postfix: '-aarch64-pc-windows-msvc.exe'
|
dotnet_name_postfix: '-aarch64-pc-windows-msvc.exe'
|
||||||
tauri_bundle: 'nsis updater'
|
tauri_bundle: 'nsis updater'
|
||||||
@ -159,14 +154,6 @@ jobs:
|
|||||||
Write-Output "Rust version: '${rust_version}'"
|
Write-Output "Rust version: '${rust_version}'"
|
||||||
Write-Output "MudBlazor version: '${mud_blazor_version}'"
|
Write-Output "MudBlazor version: '${mud_blazor_version}'"
|
||||||
Write-Output "Tauri version: '${tauri_version}'"
|
Write-Output "Tauri version: '${tauri_version}'"
|
||||||
|
|
||||||
- name: Store update platform to .updates directory (Unix)
|
|
||||||
if: matrix.platform != 'windows-latest'
|
|
||||||
run: echo ${{ matrix.update_platform }} > .updates/platform
|
|
||||||
|
|
||||||
- name: Store update platform to .updates directory (Windows)
|
|
||||||
if: matrix.platform == 'windows-latest'
|
|
||||||
run: Write-Output "${{ matrix.update_platform }}" | Out-File -FilePath ".updates/platform" -Encoding utf8 -NoNewline
|
|
||||||
|
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@v4
|
uses: actions/setup-dotnet@v4
|
||||||
@ -289,7 +276,6 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
runtime/target/${{ matrix.rust_target }}/release/bundle/dmg/MindWork AI Studio_*.dmg
|
runtime/target/${{ matrix.rust_target }}/release/bundle/dmg/MindWork AI Studio_*.dmg
|
||||||
runtime/target/${{ matrix.rust_target }}/release/bundle/macos/MindWork AI Studio.app.tar.gz*
|
runtime/target/${{ matrix.rust_target }}/release/bundle/macos/MindWork AI Studio.app.tar.gz*
|
||||||
.updates/platform
|
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: ${{ env.RETENTION_INTERMEDIATE_ASSETS }}
|
retention-days: ${{ env.RETENTION_INTERMEDIATE_ASSETS }}
|
||||||
|
|
||||||
@ -301,7 +287,6 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
runtime/target/${{ matrix.rust_target }}/release/bundle/msi/MindWork AI Studio_*.msi
|
runtime/target/${{ matrix.rust_target }}/release/bundle/msi/MindWork AI Studio_*.msi
|
||||||
runtime/target/${{ matrix.rust_target }}/release/bundle/msi/MindWork AI Studio*msi.zip*
|
runtime/target/${{ matrix.rust_target }}/release/bundle/msi/MindWork AI Studio*msi.zip*
|
||||||
.updates/platform
|
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: ${{ env.RETENTION_INTERMEDIATE_ASSETS }}
|
retention-days: ${{ env.RETENTION_INTERMEDIATE_ASSETS }}
|
||||||
|
|
||||||
@ -313,7 +298,6 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
runtime/target/${{ matrix.rust_target }}/release/bundle/nsis/MindWork AI Studio_*.exe
|
runtime/target/${{ matrix.rust_target }}/release/bundle/nsis/MindWork AI Studio_*.exe
|
||||||
runtime/target/${{ matrix.rust_target }}/release/bundle/nsis/MindWork AI Studio*nsis.zip*
|
runtime/target/${{ matrix.rust_target }}/release/bundle/nsis/MindWork AI Studio*nsis.zip*
|
||||||
.updates/platform
|
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: ${{ env.RETENTION_INTERMEDIATE_ASSETS }}
|
retention-days: ${{ env.RETENTION_INTERMEDIATE_ASSETS }}
|
||||||
|
|
||||||
@ -324,7 +308,6 @@ jobs:
|
|||||||
name: MindWork AI Studio (Linux - deb ${{ matrix.dotnet_runtime }})
|
name: MindWork AI Studio (Linux - deb ${{ matrix.dotnet_runtime }})
|
||||||
path: |
|
path: |
|
||||||
runtime/target/${{ matrix.rust_target }}/release/bundle/deb/mind-work-ai-studio_*.deb
|
runtime/target/${{ matrix.rust_target }}/release/bundle/deb/mind-work-ai-studio_*.deb
|
||||||
.updates/platform
|
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: ${{ env.RETENTION_INTERMEDIATE_ASSETS }}
|
retention-days: ${{ env.RETENTION_INTERMEDIATE_ASSETS }}
|
||||||
|
|
||||||
@ -336,7 +319,6 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
runtime/target/${{ matrix.rust_target }}/release/bundle/appimage/mind-work-ai-studio_*.AppImage
|
runtime/target/${{ matrix.rust_target }}/release/bundle/appimage/mind-work-ai-studio_*.AppImage
|
||||||
runtime/target/${{ matrix.rust_target }}/release/bundle/appimage/mind-work-ai-studio*AppImage.tar.gz*
|
runtime/target/${{ matrix.rust_target }}/release/bundle/appimage/mind-work-ai-studio*AppImage.tar.gz*
|
||||||
.updates/platform
|
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: ${{ env.RETENTION_INTERMEDIATE_ASSETS }}
|
retention-days: ${{ env.RETENTION_INTERMEDIATE_ASSETS }}
|
||||||
|
|
||||||
@ -403,9 +385,6 @@ jobs:
|
|||||||
echo "Rust version: '${rust_version}'"
|
echo "Rust version: '${rust_version}'"
|
||||||
echo "MudBlazor version: '${mud_blazor_version}'"
|
echo "MudBlazor version: '${mud_blazor_version}'"
|
||||||
echo "Tauri version: '${tauri_version}'"
|
echo "Tauri version: '${tauri_version}'"
|
||||||
|
|
||||||
- name: Store update platform to .updates directory
|
|
||||||
run: echo "linux-aarch64" > .updates/platform
|
|
||||||
|
|
||||||
- name: Setup .NET
|
- name: Setup .NET
|
||||||
uses: actions/setup-dotnet@v4
|
uses: actions/setup-dotnet@v4
|
||||||
@ -539,7 +518,6 @@ jobs:
|
|||||||
name: MindWork AI Studio (Linux - deb linux-arm64)
|
name: MindWork AI Studio (Linux - deb linux-arm64)
|
||||||
path: |
|
path: |
|
||||||
result/target/aarch64-unknown-linux-gnu/release/bundle/deb/mind-work-ai-studio_*.deb
|
result/target/aarch64-unknown-linux-gnu/release/bundle/deb/mind-work-ai-studio_*.deb
|
||||||
.updates/platform
|
|
||||||
if-no-files-found: warn
|
if-no-files-found: warn
|
||||||
retention-days: ${{ env.RETENTION_INTERMEDIATE_ASSETS }}
|
retention-days: ${{ env.RETENTION_INTERMEDIATE_ASSETS }}
|
||||||
|
|
||||||
@ -668,41 +646,52 @@ jobs:
|
|||||||
|
|
||||||
echo "Processing signature file '$sig_file':"
|
echo "Processing signature file '$sig_file':"
|
||||||
|
|
||||||
# Extract the platform directory. First, we start at the location of the signature file:
|
#
|
||||||
platform_dir=$(dirname "$sig_file")
|
# Next, we determine the "update platform". We use a if/elseif construct.
|
||||||
|
# We store the result in the $platform variable.
|
||||||
# Iterate up the directory tree until we find the platform file.
|
#
|
||||||
# When we reach the artifacts directory, we stop.
|
# We derive the platform from the path and the signature file name:
|
||||||
while [[ "$platform_dir" != "$GITHUB_WORKSPACE/artifacts" ]]; do
|
# - platform=darwin-aarch64 when path contains 'aarch64-apple-darwin'
|
||||||
if [[ -f "$platform_dir/.updates/platform" ]]; then
|
# - platform=darwin-x86_64 when path contains 'x86_64-apple-darwin'
|
||||||
echo " Found platform file in '$platform_dir/.updates/platform' for signature file '$sig_file'."
|
# - platform=linux-x86_64 when path contains 'x86_64-unknown-linux-'
|
||||||
break
|
# - platform=windows-x86_64 when path contains 'x86_64-pc-windows-'
|
||||||
fi
|
# - platform=windows-aarch64 when path contains 'aarch64-pc-windows-'
|
||||||
|
#
|
||||||
# Go up one directory level:
|
if [[ "$sig_file" == *"aarch64-apple-darwin"* ]]; then
|
||||||
platform_dir=$(dirname "$platform_dir")
|
platform="darwin-aarch64"
|
||||||
echo " Going up to '$platform_dir'."
|
elif [[ "$sig_file" == *"x86_64-apple-darwin"* ]]; then
|
||||||
done
|
platform="darwin-x86_64"
|
||||||
|
elif [[ "$sig_file" == *"x86_64-unknown-linux-" ]]; then
|
||||||
# Ensure that we found the platform file:
|
platform="linux-x86_64"
|
||||||
if [[ -f "$platform_dir/.updates/platform" ]]; then
|
elif [[ "$sig_file" == *"x86_64-pc-windows-" ]]; then
|
||||||
|
platform="windows-x86_64"
|
||||||
# Read the platform and signature:
|
elif [[ "$sig_file" == *"aarch64-pc-windows-" ]]; then
|
||||||
platform=$(cat "$platform_dir/.updates/platform")
|
platform="windows-aarch64"
|
||||||
signature=$(cat "$sig_file")
|
|
||||||
|
|
||||||
# Extract the artifact name and create the URL:
|
|
||||||
artifact_name=$(basename "$sig_file" .sig)
|
|
||||||
encoded_artifact_name=$(urlencode "$artifact_name")
|
|
||||||
url="https://github.com/MindWorkAI/AI-Studio/releases/download/$FORMATTED_VERSION/$encoded_artifact_name"
|
|
||||||
|
|
||||||
# Build the JSON object:
|
|
||||||
platforms_json=$(echo "$platforms_json" | jq --arg platform "$platform" --arg signature "$signature" --arg url "$url" '.[$platform] = {"signature": $signature, "url": $url}')
|
|
||||||
|
|
||||||
else
|
else
|
||||||
echo " Error: Could not find the platform file for the signature file '$sig_file'."
|
echo "Platform not recognized: '$sig_file'"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
done < <(find $GITHUB_WORKSPACE/artifacts -type f -name '*.sig' -print0)
|
|
||||||
|
# Read the signature:
|
||||||
|
signature=$(cat "$sig_file")
|
||||||
|
|
||||||
|
# Extract the artifact name and create the URL:
|
||||||
|
artifact_name=$(basename "$sig_file" .sig)
|
||||||
|
encoded_artifact_name=$(urlencode "$artifact_name")
|
||||||
|
url="
|
||||||
|
|
||||||
|
# Read the signature:
|
||||||
|
signature=$(cat "$sig_file")
|
||||||
|
|
||||||
|
# Extract the artifact name and create the URL:
|
||||||
|
artifact_name=$(basename "$sig_file" .sig)
|
||||||
|
encoded_artifact_name=$(urlencode "$artifact_name")
|
||||||
|
url="https://github.com/MindWorkAI/AI-Studio/releases/download/$FORMATTED_VERSION/$encoded_artifact_name"
|
||||||
|
|
||||||
|
# Build the JSON object:
|
||||||
|
platforms_json=$(echo "$platforms_json" | jq --arg platform "$platform" --arg signature "$signature" --arg url "$url" '.[$platform] = {"signature": $signature, "url": $url}')
|
||||||
|
|
||||||
|
done < <(find $GITHUB_WORKSPACE/release/assets -type f -name '*.sig' -print0)
|
||||||
|
|
||||||
# Write the JSON object to a temporary file:
|
# Write the JSON object to a temporary file:
|
||||||
echo "$platforms_json" > $GITHUB_WORKSPACE/.updates/platforms.json
|
echo "$platforms_json" > $GITHUB_WORKSPACE/.updates/platforms.json
|
||||||
|
Loading…
Reference in New Issue
Block a user