Skip to content

feat: 更新输出统一进 update.log,重启操作日志(run.log)收尾追加进 update.log, #34

feat: 更新输出统一进 update.log,重启操作日志(run.log)收尾追加进 update.log,

feat: 更新输出统一进 update.log,重启操作日志(run.log)收尾追加进 update.log, #34

Workflow file for this run

name: Build Sub-Store module
on:
workflow_dispatch:
inputs:
abi:
description: '目标 ABI (all=全部 4 架构)'
default: all
type: choice
options: [all, arm64-v8a, armeabi-v7a, x86_64, x86]
version:
description: 基础版本号 (留空则取 git tag, 如 v1.0.0)
default: ''
push:
tags: ['v*']
permissions:
contents: write
jobs:
metadata:
runs-on: ubuntu-latest
outputs:
abi-matrix: ${{ steps.meta.outputs.abi-matrix }}
version: ${{ steps.meta.outputs.version }}
build-type: ${{ steps.meta.outputs.build-type }}
is-tag: ${{ steps.meta.outputs.is-tag }}
is-prerelease: ${{ steps.meta.outputs.is-prerelease }}
publish-update-json: ${{ steps.meta.outputs.publish-update-json }}
steps:
- id: meta
shell: bash
run: |
if [ "${{ inputs.abi || 'all' }}" = "all" ]; then
echo 'abi-matrix=["arm64-v8a","armeabi-v7a","x86_64","x86"]' >> "$GITHUB_OUTPUT"
else
printf 'abi-matrix=["%s"]\n' "${{ inputs.abi }}" >> "$GITHUB_OUTPUT"
fi
tag="${GITHUB_REF_NAME:-}"
version="${{ inputs.version }}"
[ -n "$version" ] || version="$tag"
echo "version=$version" >> "$GITHUB_OUTPUT"
is_tag=false
is_prerelease=false
publish_update_json=false
build_type=release
# hotfix 属于稳定版修订,不按 prerelease 处理;alpha/beta/rc 才算预发布。
if [[ "$version" =~ -(alpha|beta|rc)([.-]|$) ]]; then
is_prerelease=true
build_type=prerelease
elif [[ "$version" == *-hotfix* ]]; then
build_type=hotfix
fi
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
is_tag=true
# SemVer prerelease tags look like v1.2.3-alpha.1. GitHub release
# gets marked prerelease, and gh-pages update JSON stays on stable.
if [ "$is_prerelease" = "false" ]; then
publish_update_json=true
fi
fi
echo "is-tag=$is_tag" >> "$GITHUB_OUTPUT"
echo "is-prerelease=$is_prerelease" >> "$GITHUB_OUTPUT"
echo "publish-update-json=$publish_update_json" >> "$GITHUB_OUTPUT"
echo "build-type=$build_type" >> "$GITHUB_OUTPUT"
webui:
needs: metadata
runs-on: ubuntu-latest
steps:
- name: Checkout WebUI repo
uses: actions/checkout@v7
with:
repository: Delusions6515/Sub-Store-Module-WebUI
path: Sub-Store-Module-WebUI
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 11.3.0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
cache-dependency-path: Sub-Store-Module-WebUI/pnpm-lock.yaml
- name: Build WebUI
run: |
cd Sub-Store-Module-WebUI
pnpm install --frozen-lockfile
pnpm build
ls -lh dist/
- name: Upload WebUI artifact
uses: actions/upload-artifact@v7
with:
name: sub-store-webui-dist
path: Sub-Store-Module-WebUI/dist
if-no-files-found: error
build:
needs: [metadata, webui]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
abi: ${{ fromJSON(needs.metadata.outputs.abi-matrix) }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # 完整历史: versionCode 取 git 提交数 (ZygiskNext 风格)
- name: Download WebUI artifact
uses: actions/download-artifact@v7
with:
name: sub-store-webui-dist
path: webui-dist
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y zip unzip xz-utils
- name: Build module
env:
TARGET_ABI: ${{ matrix.abi }}
BUILD_TYPE: ${{ needs.metadata.outputs.build-type }}
WEBUI_DIST_DIR: ${{ github.workspace }}/webui-dist
run: |
./build.sh "${{ needs.metadata.outputs.version }}"
ls -lh build/*.zip
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: sub-store-module-${{ matrix.abi }}
path: build/*.zip
if-no-files-found: error
release:
needs: [metadata, build]
if: needs.metadata.outputs.is-tag == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/download-artifact@v7
with:
path: dist
merge-multiple: true
- name: Generate release notes
env:
TAG: ${{ github.ref_name }}
BUILD_TYPE: ${{ needs.metadata.outputs.build-type }}
run: |
args=(--tag "$TAG" --build-type "$BUILD_TYPE")
[ "$BUILD_TYPE" = "release" ] && args+=(--stable-only)
python3 gen-changelog.py "${args[@]}" > release-notes.md
printf '\n构建记录: %s/%s/actions/runs/%s\n' \
"${{ github.server_url }}" "${{ github.repository }}" "${{ github.run_id }}" >> release-notes.md
cat release-notes.md
- name: Create or update release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
PRERELEASE: ${{ needs.metadata.outputs.is-prerelease }}
run: |
args=(--title "Sub-Store for Android $TAG" --notes-file release-notes.md)
[ "$PRERELEASE" = "true" ] && args+=(--prerelease --latest=false)
if gh release view "$TAG" >/dev/null 2>&1; then
gh release edit "$TAG" "${args[@]}"
else
gh release create "$TAG" "${args[@]}"
fi
gh release upload "$TAG" dist/*.zip --clobber
# 发布 update JSON (各架构分开), 供管理器检测稳定版更新
# module.prop 的 updateJson 指向 gh-pages 分支上的 update-<abi>.json
update-json:
needs: [metadata, release]
if: needs.metadata.outputs.publish-update-json == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Generate update JSON (各架构分开) + CHANGELOG.md
env:
TAG: ${{ github.ref_name }}
BUILD_TYPE: ${{ needs.metadata.outputs.build-type }}
run: |
VER="${TAG#v}" # version 不带 v, 与 module.prop 保持一致
CODE=$(git rev-list HEAD --count)
SHA=$(git rev-parse --short HEAD)
# 生成到独立目录 json-out/, 避免与后续 gh-pages checkout 的 untracked 文件冲突
mkdir -p json-out
for abi in arm64-v8a armeabi-v7a x86_64 x86; do
# zipUrl 文件名里的构建类型与 release 资产的命名对齐 (release/hotfix)
ZIP="sub-store-module-${VER}-${CODE}-${SHA}-${BUILD_TYPE}-${abi}.zip"
cat > "json-out/update-${abi}.json" <<JSON
{
"version": "$VER",
"versionCode": $CODE,
"zipUrl": "https://github.com/Delusions6515/Sub-Store-Module/releases/download/$TAG/$ZIP",
"changelog": "https://raw.githubusercontent.com/Delusions6515/Sub-Store-Module/gh-pages/CHANGELOG.md"
}
JSON
done
# CHANGELOG.md: 最近 4 个版本 (稳定/hotfix 计数, 排除 alpha/beta/rc)
python3 gen-changelog.py --stable-only --with-hotfix > json-out/CHANGELOG.md
ls -l json-out/
- name: Publish to gh-pages branch
env:
TAG: ${{ github.ref_name }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if git fetch origin gh-pages:gh-pages 2>/dev/null; then
git checkout gh-pages
else
# 首次: gh-pages 不存在, 用 orphan 分支创建 (清空索引只提交 JSON)
git checkout --orphan gh-pages
git rm -rf --cached . >/dev/null 2>&1 || git rm -rf . >/dev/null 2>&1 || true
fi
cp json-out/update-*.json json-out/CHANGELOG.md .
git add update-*.json CHANGELOG.md
if git commit -m "update json + changelog: $TAG"; then
git push origin gh-pages
else
echo "update json 无变化, 跳过推送"
fi