Introduce a manual re-dispatch workflow and wire automatic dispatch from releases to the Docker workflow. dispatch-docker-release.yml was converted to a workflow_dispatch-based "Re-dispatch Docker Release" that accepts snowluma_tag, docker_image_override and platforms_override inputs and forwards them (plus source repository) to the downstream docker-image.yml in the Docker release repo. release.yml gains a dispatch-docker job that runs after the release job and uses a PAT to invoke the same downstream workflow for newly published tags. These changes let maintainers rebuild Docker images for existing tags (e.g. to fix Dockerfile issues or rotate credentials) without re-tagging, and ensure the downstream dispatch runs under the configured token.
215 lines
7.3 KiB
YAML
215 lines
7.3 KiB
YAML
name: Build and Release
|
||
|
||
on:
|
||
push:
|
||
tags:
|
||
- 'v*'
|
||
|
||
permissions:
|
||
contents: write
|
||
|
||
jobs:
|
||
build:
|
||
strategy:
|
||
fail-fast: false
|
||
matrix:
|
||
include:
|
||
- name: win-x64
|
||
os: windows-latest
|
||
target: win32-x64
|
||
- name: linux-x64
|
||
os: ubuntu-latest
|
||
target: linux-x64
|
||
- name: linux-arm64
|
||
os: ubuntu-24.04-arm
|
||
target: linux-arm64
|
||
runs-on: ${{ matrix.os }}
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v6
|
||
with:
|
||
fetch-depth: 0
|
||
|
||
- name: Setup pnpm
|
||
uses: pnpm/action-setup@v6
|
||
with:
|
||
version: 10.28.0
|
||
run_install: false
|
||
|
||
- name: Setup Node.js
|
||
uses: actions/setup-node@v6
|
||
with:
|
||
node-version: '22'
|
||
cache: 'pnpm'
|
||
|
||
- name: Install dependencies
|
||
run: pnpm install --frozen-lockfile
|
||
|
||
# Always builds the WebUI flavor — no separate "core-only" artifact.
|
||
- name: Build project
|
||
env:
|
||
SNOWLUMA_TARGET: ${{ matrix.target }}
|
||
run: pnpm run build:all
|
||
|
||
- name: Bundle runtime dependencies
|
||
working-directory: dist
|
||
run: npm install --omit=dev
|
||
|
||
# Naming convention:
|
||
# SnowLuma-<tag>-<arch>.zip|tar.gz – zero-install (node bundled)
|
||
# SnowLuma-<tag>-<arch>-lite.zip|tar.gz – user provides Node >= 22
|
||
- name: Package (windows)
|
||
if: matrix.os == 'windows-latest'
|
||
shell: pwsh
|
||
run: |
|
||
Compress-Archive -Path "dist\*" -DestinationPath "SnowLuma-${{ github.ref_name }}-${{ matrix.name }}-lite.zip"
|
||
Copy-Item (Get-Command node).Source -Destination "dist\node.exe"
|
||
Compress-Archive -Path "dist\*" -DestinationPath "SnowLuma-${{ github.ref_name }}-${{ matrix.name }}.zip"
|
||
|
||
- name: Package (linux)
|
||
if: startsWith(matrix.os, 'ubuntu')
|
||
run: |
|
||
chmod +x dist/launcher.sh
|
||
tar -czf "SnowLuma-${{ github.ref_name }}-${{ matrix.name }}-lite.tar.gz" -C dist .
|
||
cp "$(command -v node)" dist/node
|
||
chmod +x dist/node
|
||
tar -czf "SnowLuma-${{ github.ref_name }}-${{ matrix.name }}.tar.gz" -C dist .
|
||
|
||
- name: Upload build artifacts
|
||
uses: actions/upload-artifact@v7
|
||
with:
|
||
name: release-${{ matrix.name }}
|
||
path: SnowLuma-${{ github.ref_name }}-${{ matrix.name }}*
|
||
if-no-files-found: error
|
||
retention-days: 1
|
||
|
||
release:
|
||
needs: build
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Checkout (for git log)
|
||
uses: actions/checkout@v6
|
||
with:
|
||
fetch-depth: 0
|
||
|
||
- name: Download all artifacts
|
||
uses: actions/download-artifact@v7
|
||
with:
|
||
path: artifacts
|
||
|
||
- name: Collect release assets
|
||
run: |
|
||
mkdir -p release
|
||
find artifacts -type f \( -name '*.zip' -o -name '*.tar.gz' \) -exec cp {} release/ \;
|
||
ls -lh release/
|
||
|
||
- name: Generate release note
|
||
shell: bash
|
||
run: |
|
||
tag="${GITHUB_REF_NAME}"
|
||
previousTag="$(git describe --tags --abbrev=0 "${tag}^" 2>/dev/null || true)"
|
||
if [[ -n "$previousTag" ]]; then
|
||
changes="$(git log --pretty=format:'- %s (%h)' "$previousTag..$tag")"
|
||
else
|
||
changes="$(git log --pretty=format:'- %s (%h)' "$tag")"
|
||
fi
|
||
[[ -z "$changes" ]] && changes="- No commit changes detected."
|
||
cat > release-notes.md <<EOF
|
||
# SnowLuma ${tag}
|
||
|
||
## 发布概览
|
||
本次发布提供 SnowLuma 的 Windows x64 / Linux x64 / Linux arm64 构建产物,默认包含 WebUI。
|
||
|
||
## 下载说明
|
||
命名约定:
|
||
- 无后缀 \`.zip/.tar.gz\`:完整版本,内置 \`node\`/\`node.exe\` 与运行时依赖,解压即可使用。
|
||
- \`-lite\` 后缀:精简版本,不含 Node.js 运行时,需自行安装 Node.js 22+。
|
||
|
||
Windows:
|
||
- \`SnowLuma-${tag}-win-x64.zip\`
|
||
- \`SnowLuma-${tag}-win-x64-lite.zip\`
|
||
|
||
Linux x64:
|
||
- \`SnowLuma-${tag}-linux-x64.tar.gz\`
|
||
- \`SnowLuma-${tag}-linux-x64-lite.tar.gz\`
|
||
|
||
Linux arm64:
|
||
- \`SnowLuma-${tag}-linux-arm64.tar.gz\`
|
||
- \`SnowLuma-${tag}-linux-arm64-lite.tar.gz\`
|
||
|
||
## 更新内容
|
||
${changes}
|
||
|
||
## 使用说明
|
||
- Windows x64:\`launcher.bat\` 或 \`node index.mjs\`。
|
||
- Linux:\`./launcher.sh\` 或 \`node index.mjs\`。
|
||
- 所有压缩包均已内置 WebUI 静态资源;启动后访问 http://localhost:5099。
|
||
- Linux 版本仅提供 OneBot 桥接能力,NTQQ 进程注入仅在 Windows 下生效。
|
||
EOF
|
||
|
||
- name: Create GitHub Release
|
||
uses: softprops/action-gh-release@v2
|
||
with:
|
||
files: |
|
||
release/*.zip
|
||
release/*.tar.gz
|
||
body_path: release-notes.md
|
||
overwrite_files: true
|
||
draft: false
|
||
prerelease: ${{ contains(github.ref_name, '-') }}
|
||
|
||
# Triggers the Docker image build on SnowLuma.Docker.Framework once the
|
||
# GitHub Release (and its per-arch tarballs) is published, so the Docker
|
||
# workflow can pull the matching `SnowLuma-<tag>-linux-<arch>-lite.tar.gz`
|
||
# asset and bake it into the container.
|
||
#
|
||
# Chained as a job dependency rather than via `on: release: published`
|
||
# because workflows triggered by GITHUB_TOKEN cannot fire downstream
|
||
# workflow events (GitHub anti-loop safeguard). Doing it as `needs: release`
|
||
# keeps the dispatch under our PAT.
|
||
dispatch-docker:
|
||
needs: release
|
||
runs-on: ubuntu-latest
|
||
environment: SnowLuma
|
||
steps:
|
||
- name: Trigger Docker.Framework workflow_dispatch
|
||
uses: actions/github-script@v8
|
||
env:
|
||
RELEASE_REPOSITORY: ${{ vars.DOCKER_RELEASE_REPOSITORY }}
|
||
DOCKER_IMAGE: ${{ vars.DOCKER_IMAGE }}
|
||
DOCKER_PLATFORMS: ${{ vars.DOCKER_PLATFORMS }}
|
||
DOCKER_WORKFLOW: ${{ vars.DOCKER_WORKFLOW }}
|
||
DOCKER_REF: ${{ vars.DOCKER_REF }}
|
||
with:
|
||
github-token: ${{ secrets.DOCKER_RELEASE_TOKEN }}
|
||
script: |
|
||
const target = process.env.RELEASE_REPOSITORY;
|
||
if (!target || !target.includes('/')) {
|
||
throw new Error('Set SnowLuma environment variable DOCKER_RELEASE_REPOSITORY to owner/repo.');
|
||
}
|
||
|
||
const [owner, repo] = target.split('/');
|
||
const tag = context.ref.replace('refs/tags/', '');
|
||
const sourceRepo = context.repo.owner + '/' + context.repo.repo;
|
||
const image = process.env.DOCKER_IMAGE || 'motricseven7/snowluma';
|
||
const platforms = process.env.DOCKER_PLATFORMS || 'linux/amd64,linux/arm64';
|
||
const workflowId = process.env.DOCKER_WORKFLOW || 'docker-image.yml';
|
||
const ref = process.env.DOCKER_REF || 'main';
|
||
|
||
await github.rest.actions.createWorkflowDispatch({
|
||
owner,
|
||
repo,
|
||
workflow_id: workflowId,
|
||
ref,
|
||
inputs: {
|
||
image,
|
||
tag,
|
||
push: 'true',
|
||
platforms,
|
||
snowluma_tag: tag,
|
||
snowluma_repository: sourceRepo,
|
||
},
|
||
});
|
||
|
||
core.info(`Dispatched ${workflowId}@${ref} on ${target} for SnowLuma release ${sourceRepo}@${tag} (image=${image}, platforms=${platforms}).`);
|