Files
ChuBlog/.github/workflows/release.yml
T

164 lines
5.1 KiB
YAML

# 发版流水线:构建 Windows 与 Linux 安装包,验证后上传 Release。
#
# 资源命名(install.sh / install.ps1 按 <os>-<arch> 挑资源,见 scripts/install.sh):
# chusql-linux-x86_64.tar.gz chusql-windows-x86_64.zip
#
# 一个平台一个包,里面 Web 前端与命令行客户端两部分都在;装哪几个由包内的安装脚本
# 当场问(非交互时用 --component / -Component 指定)。
#
# 装的人拿到的就是编好的二进制,不需要 GHC / Rust:
# curl -fsSL https://raw.githubusercontent.com/TheBadRoger/ChuSQL/main/scripts/install.sh \
# | sh -s -- --component web
# 没有对应平台的资源时,同一个脚本可以退回本地编译:
# sh scripts/install.sh --component web --from-source
#
name: release
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
tag:
description: 'tag to build and publish (must already exist)'
required: true
permissions:
contents: write
concurrency:
group: release-${{ inputs.tag || github.ref_name }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
validate:
uses: ./.github/workflows/linux.yml
with:
phase: release
build:
name: ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
timeout-minutes: 150
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, platform: linux-x86_64 }
- { os: windows-latest, platform: windows-x86_64 }
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
# ---------- 工具链 ----------
- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
chusql-core/storage/target
key: ${{ runner.os }}-${{ matrix.platform }}-cargo-${{ hashFiles('chusql-core/storage/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Haskell toolchain
uses: haskell-actions/setup@v2
with:
ghc-version: '9.10.3'
enable-stack: true
stack-version: '3.11.1'
- name: Cache stack
uses: actions/cache@v4
with:
path: |
~/.stack
chusql-core/engine/.stack-work
chusql-web/.stack-work
chusql-cli/.stack-work
key: ${{ runner.os }}-${{ matrix.platform }}-stack-${{ hashFiles('**/stack.yaml', '**/stack.yaml.lock') }}
restore-keys: ${{ runner.os }}-stack-
# ---------- 构建 ----------
- name: build storage (Rust)
working-directory: chusql-core/storage
run: cargo build --release
- name: build web front end
working-directory: chusql-cli
run: stack build --fast chusql-web:exe:chusql-web
- name: build cli
working-directory: chusql-cli
run: stack build --fast chusql-cli:exe:csql
- name: build tcp server
working-directory: chusql-cli
run: stack build --fast chusql-server:exe:chusql-server
- name: build bootstrap program
working-directory: chusql-bootstrap
run: stack build --fast chusql-bootstrap:exe:csql-bootstrap
- name: package and verify (Unix)
if: runner.os != 'Windows'
shell: bash
run: sh scripts/package.sh --out-dir "$PWD/dist" --platform '${{ matrix.platform }}' --version '${{ inputs.tag || github.ref_name }}' --no-build
- name: package and verify (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: ./scripts/package.ps1 -OutDir dist -Platform '${{ matrix.platform }}' -Version '${{ inputs.tag || github.ref_name }}' -NoBuild
- name: checksum
shell: pwsh
run: |
Get-ChildItem dist -File | Where-Object { $_.Name -match '\.(zip|tar\.gz)$' } | ForEach-Object {
$hash = (Get-FileHash $_.FullName -Algorithm SHA256).Hash.ToLower()
"$hash $($_.Name)" | Set-Content -NoNewline "$($_.FullName).sha256"
Write-Host "$($_.Name) $hash"
}
- name: upload
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}
path: |
dist/*.zip
dist/*.tar.gz
dist/*.sha256
if-no-files-found: error
publish:
name: publish release
needs: [build, validate]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag || github.ref }}
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: attach assets to the release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag || github.ref_name }}
run: |
set -eu
ls -l dist
notes="docs/release-$TAG.md"
test -f "$notes"
gh release view "$TAG" >/dev/null 2>&1 || gh release create "$TAG" --title "ChuSQL $TAG" --notes-file "$notes" --verify-tag
gh release edit "$TAG" --notes-file "$notes"
gh release upload "$TAG" dist/* --clobber