mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
* ci: keep dev builds published and document them The dev release was emptied before every build: the cleanup job deleted all weed-* assets first, and cancel-in-progress cancelled the build on the next master push. Build the platforms with one prepare timestamp, upload first, then prune assets from older builds. Queue runs instead of cancelling them, and allow manual runs from master only. Document the dev binaries and the :dev container images in the README and docker/README.md. Refs #5009 * ci: key dev build concurrency by ref A workflow_dispatch from another branch joined the single dev group and replaced the pending master run before failing its ref guard, so the newest master commit was never built. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: keep newer dev builds when an older run retries A "Re-run failed jobs" of an older run keeps that run's BUILD_TIME, so its prune treated a newer complete build as stale and deleted it. Prune now deletes only assets whose stamp sorts before BUILD_TIME. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
257 lines
8.7 KiB
YAML
257 lines
8.7 KiB
YAML
name: "rust: build dev volume server binaries"
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
paths:
|
|
- 'seaweed-volume/**'
|
|
- 'seaweed-common/**'
|
|
- '.github/workflows/rust_binaries_dev.yml'
|
|
workflow_dispatch:
|
|
|
|
# Serialize dev builds of the shared "dev" release without cancelling a run.
|
|
concurrency:
|
|
group: rust-binaries-dev-${{ github.ref }}
|
|
cancel-in-progress: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
|
|
prepare:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
build_time: ${{ steps.build_time.outputs.value }}
|
|
steps:
|
|
- name: Ref guard
|
|
if: github.ref != 'refs/heads/master'
|
|
env:
|
|
GH_REF: ${{ github.ref }}
|
|
run: |
|
|
echo "dev builds only publish from master (got $GH_REF)" >&2
|
|
exit 1
|
|
|
|
- name: Set BUILD_TIME
|
|
id: build_time
|
|
run: |
|
|
echo "value=$(date -u +%Y%m%d-%H%M)" >> "$GITHUB_OUTPUT"
|
|
|
|
build-rust-volume-dev-linux:
|
|
permissions:
|
|
contents: write
|
|
needs: prepare
|
|
runs-on: ubuntu-24.04
|
|
env:
|
|
BUILD_TIME: ${{ needs.prepare.outputs.build_time }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- target: x86_64-unknown-linux-gnu
|
|
asset_suffix: linux-amd64
|
|
|
|
steps:
|
|
|
|
- name: Validate BUILD_TIME
|
|
run: |
|
|
: "${BUILD_TIME:?prepare output missing}"
|
|
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: Cache cargo registry and target
|
|
if: runner.environment == 'github-hosted'
|
|
uses: actions/cache@v6
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
seaweed-volume/target
|
|
key: rust-dev-${{ matrix.target }}-${{ hashFiles('seaweed-volume/Cargo.lock') }}
|
|
restore-keys: |
|
|
rust-dev-${{ matrix.target }}-
|
|
|
|
- name: Build Rust volume server (large disk)
|
|
env:
|
|
SEAWEEDFS_COMMIT: ${{ github.sha }}
|
|
run: cd seaweed-volume && cargo build --release
|
|
|
|
- name: Package large disk binary
|
|
run: |
|
|
cp seaweed-volume/target/release/weed-volume weed-volume-large-disk
|
|
tar czf "weed-volume-large-disk-${{ env.BUILD_TIME }}-${{ matrix.asset_suffix }}.tar.gz" weed-volume-large-disk
|
|
rm weed-volume-large-disk
|
|
|
|
- name: Build Rust volume server (normal)
|
|
env:
|
|
SEAWEEDFS_COMMIT: ${{ github.sha }}
|
|
run: cd seaweed-volume && cargo build --release --no-default-features
|
|
|
|
- name: Package normal binary
|
|
run: |
|
|
cp seaweed-volume/target/release/weed-volume weed-volume-normal
|
|
tar czf "weed-volume-${{ env.BUILD_TIME }}-${{ matrix.asset_suffix }}.tar.gz" weed-volume-normal
|
|
rm weed-volume-normal
|
|
|
|
- name: Upload dev release assets
|
|
uses: softprops/action-gh-release@v3
|
|
with:
|
|
tag_name: dev
|
|
prerelease: true
|
|
files: |
|
|
weed-volume-large-disk-${{ env.BUILD_TIME }}-${{ matrix.asset_suffix }}.tar.gz
|
|
weed-volume-${{ env.BUILD_TIME }}-${{ matrix.asset_suffix }}.tar.gz
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
build-rust-volume-dev-darwin:
|
|
permissions:
|
|
contents: write
|
|
needs: [prepare, build-rust-volume-dev-linux]
|
|
runs-on: macos-latest
|
|
env:
|
|
BUILD_TIME: ${{ needs.prepare.outputs.build_time }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- target: aarch64-apple-darwin
|
|
asset_suffix: darwin-arm64
|
|
- target: x86_64-apple-darwin
|
|
asset_suffix: darwin-amd64
|
|
|
|
steps:
|
|
|
|
- name: Validate BUILD_TIME
|
|
run: |
|
|
: "${BUILD_TIME:?prepare output missing}"
|
|
|
|
- uses: actions/checkout@v7
|
|
|
|
- name: Install Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Cache cargo registry and target
|
|
if: runner.environment == 'github-hosted'
|
|
uses: actions/cache@v6
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
seaweed-volume/target
|
|
key: rust-dev-${{ matrix.target }}-${{ hashFiles('seaweed-volume/Cargo.lock') }}
|
|
restore-keys: |
|
|
rust-dev-${{ matrix.target }}-
|
|
|
|
- name: Build Rust volume server (large disk)
|
|
env:
|
|
SEAWEEDFS_COMMIT: ${{ github.sha }}
|
|
run: cd seaweed-volume && cargo build --release --target ${{ matrix.target }}
|
|
|
|
- name: Package large disk binary
|
|
run: |
|
|
cp seaweed-volume/target/${{ matrix.target }}/release/weed-volume weed-volume-large-disk
|
|
tar czf "weed-volume-large-disk-${{ env.BUILD_TIME }}-${{ matrix.asset_suffix }}.tar.gz" weed-volume-large-disk
|
|
rm weed-volume-large-disk
|
|
|
|
- name: Build Rust volume server (normal)
|
|
env:
|
|
SEAWEEDFS_COMMIT: ${{ github.sha }}
|
|
run: cd seaweed-volume && cargo build --release --target ${{ matrix.target }} --no-default-features
|
|
|
|
- name: Package normal binary
|
|
run: |
|
|
cp seaweed-volume/target/${{ matrix.target }}/release/weed-volume weed-volume-normal
|
|
tar czf "weed-volume-${{ env.BUILD_TIME }}-${{ matrix.asset_suffix }}.tar.gz" weed-volume-normal
|
|
rm weed-volume-normal
|
|
|
|
- name: Upload dev release assets
|
|
uses: softprops/action-gh-release@v3
|
|
with:
|
|
tag_name: dev
|
|
prerelease: true
|
|
files: |
|
|
weed-volume-large-disk-${{ env.BUILD_TIME }}-${{ matrix.asset_suffix }}.tar.gz
|
|
weed-volume-${{ env.BUILD_TIME }}-${{ matrix.asset_suffix }}.tar.gz
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
prune:
|
|
needs: [prepare, build-rust-volume-dev-linux, build-rust-volume-dev-darwin]
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
permissions:
|
|
contents: write
|
|
env:
|
|
BUILD_TIME: ${{ needs.prepare.outputs.build_time }}
|
|
RELEASE_TAG: dev
|
|
steps:
|
|
- name: Delete Rust dev binaries from older builds
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
: "${BUILD_TIME:?BUILD_TIME is empty}"
|
|
case "$BUILD_TIME" in
|
|
[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]) ;;
|
|
*) echo "Invalid BUILD_TIME: $BUILD_TIME" >&2; exit 1 ;;
|
|
esac
|
|
|
|
release_tag="${RELEASE_TAG:-dev}"
|
|
if ! release_json=$(gh api "repos/$GITHUB_REPOSITORY/releases/tags/$release_tag" 2>&1); then
|
|
case "$release_json" in
|
|
*"Not Found"*) echo "No $release_tag release; nothing to prune"; exit 0 ;;
|
|
esac
|
|
echo "Release lookup failed: $release_json" >&2
|
|
exit 1
|
|
fi
|
|
release_id=$(jq -r '.id // empty' <<<"$release_json")
|
|
if [ -z "$release_id" ]; then
|
|
echo "Release lookup returned no id" >&2
|
|
exit 1
|
|
fi
|
|
|
|
assets_file=$(mktemp)
|
|
trap 'rm -f "$assets_file"' EXIT
|
|
if ! gh api "repos/$GITHUB_REPOSITORY/releases/$release_id/assets" --paginate \
|
|
--jq '.[] | select(.name | startswith("weed-volume-")) | [.id, .name] | @tsv' \
|
|
> "$assets_file"; then
|
|
echo "Failed to list release assets" >&2
|
|
exit 1
|
|
fi
|
|
|
|
total=$(awk 'END{print NR+0}' "$assets_file")
|
|
matching=$(awk -v s="-$BUILD_TIME-" 'index($0,s){n++} END{print n+0}' "$assets_file")
|
|
if [ "$matching" -eq 0 ]; then
|
|
echo "No assets carry stamp $BUILD_TIME; refusing to prune" >&2
|
|
exit 1
|
|
fi
|
|
|
|
build_key=${BUILD_TIME/-/}
|
|
kept=0; newer=0; deleted=0; gone=0; failed=0
|
|
while IFS=$'\t' read -r id name || [ -n "${name:-}" ]; do
|
|
[ -n "${id:-}" ] || continue
|
|
case "$name" in
|
|
*"-$BUILD_TIME-"*) kept=$((kept+1)); continue ;;
|
|
esac
|
|
if [[ "$name" =~ -([0-9]{8})-([0-9]{4})- ]] && [ "${BASH_REMATCH[1]}${BASH_REMATCH[2]}" -gt "$build_key" ]; then
|
|
newer=$((newer+1)); continue
|
|
fi
|
|
if out=$(gh api -X DELETE "repos/$GITHUB_REPOSITORY/releases/assets/$id" </dev/null 2>&1); then
|
|
deleted=$((deleted+1))
|
|
else
|
|
case "$out" in
|
|
*"Not Found"*) gone=$((gone+1)) ;;
|
|
*) failed=$((failed+1)); echo "Failed to delete asset $name ($id): $out" >&2 ;;
|
|
esac
|
|
fi
|
|
done < "$assets_file"
|
|
|
|
[ "$((kept+newer+deleted+gone+failed))" -eq "$total" ] || { echo "Processed $((kept+newer+deleted+gone+failed)) of $total assets" >&2; exit 1; }
|
|
echo "Kept $kept assets from this build and $newer from newer builds; deleted $deleted older assets; $gone already gone; $failed failures"
|
|
[ "$failed" -eq 0 ] || { echo "::warning::prune: $failed deletions failed"; exit 1; }
|