Skip to content

fix: only publish release archives #4

fix: only publish release archives

fix: only publish release archives #4

Workflow file for this run

name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "要发布的版本号,例如 1.3.0"
required: true
tag:
description: "目标标签,例如 v1.3.0"
required: true
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- runner: windows-latest
target: windows-x64
- runner: macos-15-intel
target: macos-x64
- runner: macos-15
target: macos-arm64
- runner: ubuntu-24.04
target: linux-x64
- runner: ubuntu-24.04-arm
target: linux-arm64
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Sync dependencies
run: uv sync --group dev
- name: Build binary bundle
run: uv run python scripts/build_binary_release.py --target "${{ matrix.target }}" --validate
- name: Upload release artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: |
release_artifacts/*.zip
release_artifacts/*.tar.gz
if-no-files-found: error
publish:
needs: build
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: release_artifacts
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Resolve version metadata
id: release_meta
shell: bash
run: |
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
echo "tag=${{ github.event.inputs.tag }}" >> "${GITHUB_OUTPUT}"
echo "version=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
else
tag="${GITHUB_REF_NAME}"
version="${tag#v}"
echo "tag=${tag}" >> "${GITHUB_OUTPUT}"
echo "version=${version}" >> "${GITHUB_OUTPUT}"
fi
- name: Extract release notes
run: python scripts/extract_release_notes.py --version "${{ steps.release_meta.outputs.version }}" --output RELEASE_NOTES.md
- name: Publish GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
mapfile -t files < <(find release_artifacts -maxdepth 2 -type f \( -name "PyRAG-Kit-*.zip" -o -name "PyRAG-Kit-*.tar.gz" \) | sort)
if [ "${#files[@]}" -eq 0 ]; then
echo "未找到发布产物。" >&2
exit 1
fi
if gh release view "${{ steps.release_meta.outputs.tag }}" >/dev/null 2>&1; then
gh release upload "${{ steps.release_meta.outputs.tag }}" "${files[@]}" --clobber
else
gh release create "${{ steps.release_meta.outputs.tag }}" "${files[@]}" \
--title "${{ steps.release_meta.outputs.tag }}" \
--notes-file RELEASE_NOTES.md
fi