Skip to content

perf: optimize version list loading logic #230

perf: optimize version list loading logic

perf: optimize version list loading logic #230

Workflow file for this run

name: LeviLauncher build
on:
push:
tags:
- "v*"
branches:
- "**"
pull_request:
jobs:
build:
strategy:
fail-fast: false
matrix:
build:
[
{
name: LeviLauncher,
platform: windows/amd64,
archs: amd64,
os: windows-2022,
},
]
runs-on: ${{ matrix.build.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: ToQuery/wails3-build-action@v3-alpha.14
with:
go-archs: ${{ matrix.build.archs }}
build-name: ${{ matrix.build.name }}
build-platform: ${{ matrix.build.platform }}
package: false
- name: Create ZIP archives
shell: pwsh
run: |
Write-Host "Creating ZIP archives for Windows ${{ matrix.build.archs }}"
cd bin
if (Test-Path "LeviLauncher.exe") {
$zipName = "LeviLauncher_windows_${{ matrix.build.archs }}.zip"
Compress-Archive -Path "LeviLauncher.exe" -DestinationPath $zipName -Force
Write-Host "Created $zipName"
} else {
Write-Host "LeviLauncher.exe not found!"
Get-ChildItem
}
Write-Host "Files in bin directory:"
Get-ChildItem
- uses: actions/upload-artifact@v4
with:
name: LeviLauncher-windows-${{ matrix.build.archs }}
path: |
bin/LeviLauncher_windows_${{ matrix.build.archs }}.zip
bin/LeviLauncher-${{ matrix.build.archs }}-installer.exe
release:
name: Create Release
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: List downloaded files
run: |
echo "Downloaded artifacts:"
find ./artifacts -type f -name "*" | sort
echo "Artifacts directory structure:"
ls -R ./artifacts/
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false
generate_release_notes: true
- name: Upload Release Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Uploading release assets..."
for zip_file in ./artifacts/*/*.zip; do
if [ -f "$zip_file" ]; then
echo "Uploading ZIP: $zip_file"
gh release upload ${{ github.ref_name }} "$zip_file" --clobber
fi
done
for installer_file in ./artifacts/*/*installer.exe; do
if [ -f "$installer_file" ]; then
echo "Uploading installer: $installer_file"
gh release upload ${{ github.ref_name }} "$installer_file" --clobber
fi
done
echo "All assets uploaded successfully"
upload-to-target-repo:
name: Upload EXE to Target Repository
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: ./downloaded-artifacts
- name: Find EXE file
id: find_exe
run: |
set -euo pipefail
echo "Looking for LeviLauncher.exe in downloaded artifacts..."
EXE_FILE=$(find ./downloaded-artifacts -name "LeviLauncher.exe" -type f | head -1 || true)
if [ -z "${EXE_FILE}" ]; then
echo "LeviLauncher.exe not found directly, trying to extract ZIP artifacts..."
while IFS= read -r zip_file; do
echo "Extracting: $zip_file"
dest_dir="$(dirname "$zip_file")/extracted"
mkdir -p "$dest_dir"
unzip -o "$zip_file" -d "$dest_dir"
done < <(find ./downloaded-artifacts -name "*.zip" -type f)
EXE_FILE=$(find ./downloaded-artifacts -name "LeviLauncher.exe" -type f | head -1 || true)
fi
if [ -n "${EXE_FILE}" ]; then
echo "Found EXE file: $EXE_FILE"
echo "exe_path=$EXE_FILE" >> $GITHUB_OUTPUT
else
echo "LeviLauncher.exe still not found, searching for non-installer EXE..."
OTHER_EXE=$(find ./downloaded-artifacts -name "*.exe" -type f | grep -v installer | head -1 || true)
if [ -n "${OTHER_EXE}" ]; then
echo "Found alternative EXE file: $OTHER_EXE"
echo "exe_path=$OTHER_EXE" >> $GITHUB_OUTPUT
else
echo "No suitable EXE file found"
exit 1
fi
fi
- name: Checkout target repository
uses: actions/checkout@v4
with:
repository: dreamguxiang/LeviLauncher
token: ${{ secrets.TARGET_REPO_TOKEN }}
path: target-repo
- name: Setup target repository
run: |
cd target-repo
mkdir -p windows
cp ../${{ steps.find_exe.outputs.exe_path }} windows/LeviLauncher.exe
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
if git diff --quiet; then
echo "No changes to commit"
echo "has_changes=false" >> $GITHUB_ENV
else
echo "Changes detected, preparing commit"
echo "has_changes=true" >> $GITHUB_ENV
fi
- name: Commit and push to target repository
if: env.has_changes == 'true'
run: |
cd target-repo
git add windows/LeviLauncher.exe
git commit -m "Update LeviLauncher.exe from ${{ github.repository }}@${{ github.sha }}"
git push origin main
- name: Create tag in target repository
if: env.has_changes == 'true'
run: |
cd target-repo
TAG_NAME="${{ github.ref_name }}"
git tag -a "$TAG_NAME" -m "Release $TAG_NAME"
git push origin "$TAG_NAME"
prime-goproxy:
name: Prime GoProxy caches
needs:
- upload-to-target-repo
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Prime GoProxy caches
run: |
set -euo pipefail
TAG="${{ github.ref_name }}"
echo "Priming GoProxy caches for tag: ${TAG}"
URLS=(
"https://goproxy.io/github.com/dreamguxiang/!levi!launcher/@v/${TAG}.zip"
"https://mirrors.aliyun.com/goproxy/github.com/dreamguxiang/levilauncher/@v/${TAG}.zip"
)
for url in "${URLS[@]}"; do
echo "Requesting: ${url}"
for i in {1..5}; do
if curl -fsSL "${url}" -o /dev/null; then
echo "Primed: ${url}"
break
else
echo "Attempt ${i} failed for ${url}, retrying..."
sleep $((i*2))
fi
done
done