From 3189fbbb20003e5653d412716dbb435bb834da7e Mon Sep 17 00:00:00 2001 From: Da Shen Date: Sat, 21 Mar 2026 15:55:45 +0800 Subject: [PATCH] =?UTF-8?q?[200=5F42]=20=E6=89=93=E5=8C=85=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81=E6=94=AF=E6=8C=81=20tag=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=20Release=20=E5=92=8C=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=EF=BC=8C=E7=BB=9F=E4=B8=80=E5=8C=85=E5=90=8D?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/package.yml | 93 +++++++++++++++++++++++++++++------ xmake.lua | 6 ++- 2 files changed, 82 insertions(+), 17 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 995b7b6c..4d65e920 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -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 @@ -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 @@ -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: @@ -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: @@ -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 diff --git a/xmake.lua b/xmake.lua index dc10e937..a66cd946 100644 --- a/xmake.lua +++ b/xmake.lua @@ -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)