Skip to content

[200_1] Bump version to 17.11.31 (#522) #183

[200_1] Bump version to 17.11.31 (#522)

[200_1] Bump version to 17.11.31 (#522) #183

Workflow file for this run

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
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: 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
- 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
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:
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: 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:
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: Package
run: xmake pack -vyD goldfish
- name: Create summary table
shell: pwsh
run: |
$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
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 |"
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/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