This commit is contained in:
lily 2025-08-23 09:58:32 +10:00
parent e50fff76a2
commit 9cfe955e65

View file

@ -77,120 +77,72 @@ jobs:
with: with:
name: agg-windows-amd64 name: agg-windows-amd64
path: bin/agg.exe path: bin/agg.exe
create_release_and_upload_assets:
build_windows_aarch64: runs-on: ubuntu-latest
runs-on: windows-latest # Cross-compile from an x64 Windows runner needs: [build_linux_amd64, build_linux_aarch64, build_windows_amd64]
steps: permissions:
- name: Checkout code contents: write # Grant write permissions to the GITHUB_TOKEN for creating releases
uses: actions/checkout@v3
with: steps:
fetch-depth: 0 - name: Checkout code
uses: actions/checkout@v3
- name: Install MinGW-w64 AArch64 toolchain with:
run: | fetch-depth: 0
# Attempt to install via Choco. Package names for AArch64 MinGW can vary.
# We'll try common package names. If these fail, manual download/setup of a toolchain - name: Get latest unique tag
# from MSYS2 or similar might be needed. id: get_tag
$choco_install_ucrt = choco install mingw-w64-ucrt-aarch64 --limit-features run: |\
if ($choco_install_ucrt.ExitCode -ne 0) { LATEST_TAG=$(git tag --sort=-v:refname | head -n1 || echo "v0.0.0")
Write-Host "Failed to install mingw-w64-ucrt-aarch64" -ForegroundColor Red echo "Debug: Initial LATEST_TAG: $LATEST_TAG"\
}
NEW_TAG=""
$choco_install_none = choco install mingw-w64-arm-none-eabi --limit-features if [[ "$LATEST_TAG" =~ ^v([0-9]+)\\.([0-9]+)\\.([0-9]+)$ ]]; then
if ($choco_install_none.ExitCode -ne 0) { MAJOR=${BASH_REMATCH[1]}\
Write-Host "Failed to install mingw-w64-arm-none-eabi" -ForegroundColor Red MINOR=${BASH_REMATCH[2]}\
} PATCH=${BASH_REMATCH[3]}\
Write-Host "Could not install AArch64 MinGW via Choco. Manual intervention might be needed." -ForegroundColor Red echo "Debug: Parsed: MAJOR=$MAJOR, MINOR=$MINOR, PATCH=$PATCH"\
while : ; do
# Add the appropriate bin directory to PATH for the current session. PATCH=$((PATCH + 1))\
# This path depends on which choco package was actually installed. CANDIDATE_TAG="v$MAJOR.$MINOR.$PATCH"\
# We'll try common paths. echo "Debug: Trying CANDIDATE_TAG: $CANDIDATE_TAG"\
if (Test-Path "C:\\ProgramData\\chocolatey\\lib\\mingw-w64-ucrt-aarch64\\tools\\install\\mingw64\\bin") { if ! git rev-parse "$CANDIDATE_TAG" >/dev/null 2>&1; then
"C:\\ProgramData\\chocolatey\\lib\\mingw-w64-ucrt-aarch64\\tools\\install\\mingw64\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding Utf8 -Append NEW_TAG=$CANDIDATE_TAG\
} elseif (Test-Path "C:\\ProgramData\\chocolatey\\lib\\mingw-w64-arm-none-eabi\\tools\\install\\mingw64\\bin") { echo "Debug: Found NEW_TAG: $NEW_TAG (unused)"\
"C:\\ProgramData\\chocolatey\\lib\\mingw-w64-arm-none-eabi\\tools\\install\\mingw64\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding Utf8 -Append break\
} else { fi
Write-Host "Could not find MinGW AArch64 bin path after install. Build might fail." -ForegroundColor Yellow done
} else
shell: powershell NEW_TAG="v0.0.1"\
echo "Debug: No previous semver tags found. Setting NEW_TAG: $NEW_TAG"\
- name: Build project for Windows (AArch64) fi
run: make CC=aarch64-w64-mingw32-gcc all echo "Debug: Final LATEST_TAG for ENV: $LATEST_TAG"\
working-directory: ${{ github.workspace }} echo "Debug: Final NEW_TAG for ENV: $NEW_TAG"\
shell: pwsh # Use PowerShell for consistent path handling echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV\
echo \\"NEW_TAG=$NEW_TAG\\" >> $GITHUB_ENV
- name: Upload Windows AArch64 artifact shell: bash
uses: actions/upload-artifact@v4
with: - name: Create Release
name: agg-windows-aarch64 id: create_release
path: bin/agg.exe # Windows executables have .exe extension uses: actions/create-release@v1
env:
create_release_and_upload_assets: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest with:
needs: [build_linux_amd64, build_linux_aarch64, build_windows_amd64] tag_name: ${{ env.NEW_TAG }}
permissions: release_name: Release ${{ env.NEW_TAG }}
contents: write # Grant write permissions to the GITHUB_TOKEN for creating releases body: |\
Automated release created on push.\
steps: Commit: ${{ github.sha }}
- name: Checkout code draft: false
uses: actions/checkout@v3 prerelease: false
with:
fetch-depth: 0 - name: Download Linux AMD64 artifact
uses: actions/download-artifact@v4
- name: Get latest unique tag with:
id: get_tag name: agg-linux-amd64
run: | path: ./artifacts/linux-amd64/
LATEST_TAG=$(git tag --sort=-v:refname | head -n1 || echo "v0.0.0")
echo "Debug: Initial LATEST_TAG: $LATEST_TAG" - name: Download Linux AArch64 artifact
uses: actions/download-artifact@v4
NEW_TAG="" with:
if [[ "$LATEST_TAG" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then name: agg-linux-aarch64
MAJOR=${BASH_REMATCH[1]} path: ./artifacts/linux-aarch64/
MINOR=${BASH_REMATCH[2]}
PATCH=${BASH_REMATCH[3]}
echo "Debug: Parsed: MAJOR=$MAJOR, MINOR=$MINOR, PATCH=$PATCH"
while : ; do
PATCH=$((PATCH + 1))
CANDIDATE_TAG="v$MAJOR.$MINOR.$PATCH"
echo "Debug: Trying CANDIDATE_TAG: $CANDIDATE_TAG"
if ! git rev-parse "$CANDIDATE_TAG" >/dev/null 2>&1; then
NEW_TAG=$CANDIDATE_TAG
echo "Debug: Found NEW_TAG: $NEW_TAG (unused)"
break
fi
done
else
NEW_TAG="v0.0.1"
echo "Debug: No previous semver tags found. Setting NEW_TAG: $NEW_TAG"
fi
echo "Debug: Final LATEST_TAG for ENV: $LATEST_TAG"
echo "Debug: Final NEW_TAG for ENV: $NEW_TAG"
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
echo \"NEW_TAG=$NEW_TAG\" >> $GITHUB_ENV
shell: bash
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.NEW_TAG }}
release_name: Release ${{ env.NEW_TAG }}
body: |
Automated release created on push.
Commit: ${{ github.sha }}
draft: false
prerelease: false
- name: Download Linux AMD64 artifact
uses: actions/download-artifact@v4
with:
name: agg-linux-amd64
path: ./artifacts/linux-amd64/
- name: Download Linux AArch64 artifact
uses: actions/download-artifact@v4
with:
name: agg-linux-aarch64
path: ./artifacts/linux-aarch64/