Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 78 additions & 15 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
name: XPack Build

on:
workflow_dispatch:
inputs:
manual_version:
description: 'Set version manually (e.g. 1.2.3)'
required: false
default: ''
push:
branches:
- main
tags:
- '*'
pull_request:
branches:
- main
Expand Down Expand Up @@ -33,6 +41,28 @@ jobs:
- name: git add safe directory
run: git config --global --add safe.directory '*'

- name: Determine Version
id: get_version
run: |
REF_NAME="${{ github.ref }}"
MANUAL_VER="${{ inputs.manual_version }}"
if [ -n "$MANUAL_VER" ]; then
RAW_VERSION="$MANUAL_VER"
elif [[ "$REF_NAME" == refs/tags/* ]]; then
RAW_VERSION=${REF_NAME#refs/tags/}
RAW_VERSION=${RAW_VERSION//\//}
else
RAW_VERSION=$(date +%Y.%m.%d)
fi
if [[ "$RAW_VERSION" == v* ]]; then
CLEAN_VERSION=${RAW_VERSION#v}
else
CLEAN_VERSION="$RAW_VERSION"
fi
echo "VERSION_TAG=$RAW_VERSION" >> $GITHUB_ENV
echo "VERSION_NUM=$CLEAN_VERSION" >> $GITHUB_ENV
echo "Version tag: $RAW_VERSION"
echo "Version num: $CLEAN_VERSION"

- name: set XMAKE_GLOBALDIR
run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV
Expand Down Expand Up @@ -85,12 +115,21 @@ jobs:

- name: Upload all package artifacts
uses: actions/upload-artifact@v4
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
with:
name: goldfish-packages
path: tmp/build/xpack/goldfish/*.deb
retention-days: 30
if-no-files-found: error

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
prerelease: true
files: |
tmp/build/xpack/goldfish/*.deb

package-windows-zip:
runs-on: windows-2025
env:
Expand All @@ -110,6 +149,29 @@ jobs:
with:
fetch-depth: 1

- name: Determine Version
shell: pwsh
run: |
$refName = "${{ github.ref }}"
$manualVer = "${{ inputs.manual_version }}"
if ($manualVer) {
$rawVersion = $manualVer
} elseif ($refName -match '^refs/tags/') {
$rawVersion = $refName -replace '^refs/tags/', ''
$rawVersion = $rawVersion -replace '/', ''
} else {
$rawVersion = Get-Date -Format "yyyy.MM.dd"
}
if ($rawVersion -match '^v') {
$cleanVersion = $rawVersion.Substring(1)
} else {
$cleanVersion = $rawVersion
}
Add-Content -Path $env:GITHUB_ENV -Value "VERSION_TAG=$rawVersion"
Add-Content -Path $env:GITHUB_ENV -Value "VERSION_NUM=$cleanVersion"
Write-Host "Version tag: $rawVersion"
Write-Host "Version num: $cleanVersion"

- name: cache packages from xrepo
uses: actions/cache@v4
with:
Expand All @@ -124,37 +186,38 @@ jobs:
xmake config -vyD -o tmp/build -m release --repl=true --yes
xmake build goldfish

- name: Stage package files
shell: pwsh
run: |
$dir = "tmp/build/artifact/goldfish-windows"
if (Test-Path $dir) {
Remove-Item -Recurse -Force $dir
}
xmake install -vyD -o $dir goldfish
Get-ChildItem -Path $dir -Recurse -Filter *.pdb | Remove-Item -Force
- name: Package
run: xmake pack -vyD goldfish

- name: Create summary table
shell: pwsh
run: |
$dir = "tmp/build/artifact/goldfish-windows"
$dir = "tmp/build/xpack/goldfish"
$files = Get-ChildItem -Path $dir -Recurse -File
$size = "{0:N2} MiB" -f (($files | Measure-Object -Property Length -Sum).Sum / 1MB)
$fileCount = ($files | Measure-Object).Count
$pdbCount = (Get-ChildItem -Path $dir -Recurse -Filter *.pdb | Measure-Object).Count

Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "## Generated package files"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value ""
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "| Type | Path | Size | Files | PDB |"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "|------|------|------|-------|-----|"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "| Windows artifact | ``$dir`` | $size | $fileCount | $pdbCount |"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "| Type | Path | Size | Files |"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "|------|------|------|-------|"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "| Windows artifact | ``$dir`` | $size | $fileCount |"
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value ""
Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "*目录: ``$dir``*"

- name: Upload Windows package artifact
uses: actions/upload-artifact@v4
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
with:
name: goldfish-windows-package
path: tmp/build/artifact/goldfish-windows
path: tmp/build/xpack/goldfish/*.zip
retention-days: 30
if-no-files-found: error

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
prerelease: true
files: |
tmp/build/xpack/goldfish/*.zip
6 changes: 4 additions & 2 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ xpack ("goldfish")
add_sourcefiles("(3rdparty/**)")
on_load(function (package)
if package:with_source() then
package:set("basename", "goldfish-$(plat)-src-v$(version)")
package:set("basename", "goldfish-scheme-src-v$(version)")
elseif is_plat("windows") then
package:set("basename", "goldfish-scheme-$(arch)-v$(version)-win")
else
package:set("basename", "goldfish-$(plat)-$(arch)-v$(version)")
package:set("basename", "goldfish-scheme-$(arch)-v$(version)")
end
end)
Loading