[200_40] 新增 gf run 子命令 #175
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: XPack Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Install Dependencies | |
| run: | | |
| sudo add-apt-repository ppa:xmake-io/xmake | |
| sudo apt update | |
| sudo apt install -y git \ | |
| curl 7zip unzip curl \ | |
| gcc g++ \ | |
| devscripts debhelper build-essential \ | |
| xmake # xmake must be installed by apt (dpkg) | |
| - name: git add safe directory | |
| run: git config --global --add safe.directory '*' | |
| - name: set XMAKE_GLOBALDIR | |
| run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV | |
| - name: xmake repo --update | |
| run: xmake repo --update | |
| - name: cache packages from xrepo | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages | |
| key: ${{ runner.os }}-xrepo-${{ hashFiles('**/xmake.lua') }} | |
| - name: Config and Build | |
| run: | | |
| sed -i 's|"deb", "rpm", "srpm"|"deb"|g' xmake.lua | |
| sed -i 's|set_default(false) -- repl-anchor|set_default(true)|g' xmake.lua | |
| xmake config -vyD --policies=build.ccache -o tmp/build -m releasedbg --repl=true | |
| xmake build goldfish | |
| - name: Package | |
| run: xmake pack -vyD goldfish | |
| - name: Create summary table | |
| run: | | |
| echo "## 生成的包文件" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "| 类型 | 文件名 | 大小 | 版本 | 架构 |" >> $GITHUB_STEP_SUMMARY | |
| echo "|------|--------|------|------|------|" >> $GITHUB_STEP_SUMMARY | |
| DIR="tmp/build/xpack/goldfish" | |
| # Debian 包 | |
| for deb in "$DIR"/*.deb; do | |
| if [ -f "$deb" ]; then | |
| size=$(ls -lh "$deb" | awk '{print $5}') | |
| info=$(dpkg-deb -f "$deb" 2>/dev/null) | |
| pkg=$(echo "$info" | grep "^Package" | cut -d' ' -f2- || echo "") | |
| ver=$(echo "$info" | grep "^Version" | cut -d' ' -f2- || echo "") | |
| arch=$(echo "$info" | grep "^Architecture" | cut -d' ' -f2- || echo "") | |
| echo "| Debian | \`$(basename "$deb")\` | $size | $ver | $arch |" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| done | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "*目录: \`$DIR\`*" >> $GITHUB_STEP_SUMMARY | |
| - name: Upload all package artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: goldfish-packages | |
| path: tmp/build/xpack/goldfish/*.deb | |
| retention-days: 30 | |
| if-no-files-found: error | |
| package-windows-zip: | |
| runs-on: windows-2025 | |
| env: | |
| XMAKE_GLOBALDIR: ${{ github.workspace }}/.xmake-global | |
| steps: | |
| - name: Setup xmake | |
| uses: xmake-io/github-action-setup-xmake@v1 | |
| with: | |
| xmake-version: v2.9.9 | |
| - name: git crlf | |
| run: git config --global core.autocrlf false | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: cache packages from xrepo | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages | |
| key: ${{ runner.os }}-xrepo-${{ hashFiles('**/xmake.lua') }} | |
| - name: xmake repo --update | |
| run: xmake repo --update | |
| - name: Config and Build | |
| run: | | |
| 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: Create summary table | |
| shell: pwsh | |
| run: | | |
| $dir = "tmp/build/artifact/goldfish-windows" | |
| $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 "" | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value "*目录: ``$dir``*" | |
| - name: Upload Windows package artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: goldfish-windows-package | |
| path: tmp/build/artifact/goldfish-windows | |
| retention-days: 30 | |
| if-no-files-found: error |