From 7e34a73835e770244f4f2842343feb713d00fd3f Mon Sep 17 00:00:00 2001 From: mirivlad Date: Tue, 14 Jul 2026 01:58:30 +0800 Subject: [PATCH] build: publish portable plugin releases --- README.md | 6 ++++-- scripts/publish-github-release.sh | 30 +++++++++++++++----------- scripts/release.sh | 16 +------------- scripts/test-package-portable.sh | 1 + scripts/test-publish-github-release.sh | 13 ++++++++--- 5 files changed, 34 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 07beddc..a8749aa 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,10 @@ create a GitHub Release. The publisher requires an authenticated [`gh`](https://cli.github.com/) CLI and a clean, up-to-date `main`. It runs the local release command, creates and pushes an annotated tag if necessary, then creates or updates the GitHub -Release with the archive and `SHA256SUMS`. Re-running it for a tag that points -at the current commit replaces the release assets. +Release with the Linux archive, Windows archive and `SHA256SUMS`. Alpha, beta +and release-candidate tags are published as prereleases; stable tags are +marked latest. Re-running it for a tag that points at the current commit +replaces the release assets. ## License diff --git a/scripts/publish-github-release.sh b/scripts/publish-github-release.sh index 1758cfa..7f96923 100755 --- a/scripts/publish-github-release.sh +++ b/scripts/publish-github-release.sh @@ -39,15 +39,17 @@ fi "$RELEASE_SCRIPT" "$VERSION" -shopt -s nullglob -ASSETS=("$RELEASE_DIR"/*.tar.gz "$RELEASE_DIR"/*.tgz) -if [[ -f "$RELEASE_DIR/SHA256SUMS" ]]; then - ASSETS+=("$RELEASE_DIR/SHA256SUMS") -fi -if [[ ${#ASSETS[@]} -eq 0 ]]; then - echo "no release assets found in $RELEASE_DIR" >&2 - exit 1 -fi +ASSETS=( + "$RELEASE_DIR/verstak-official-plugins-linux-amd64-$VERSION.tar.gz" + "$RELEASE_DIR/verstak-official-plugins-windows-amd64-$VERSION.zip" + "$RELEASE_DIR/SHA256SUMS" +) +for asset in "${ASSETS[@]}"; do + if [[ ! -s "$asset" ]]; then + echo "required release asset is missing or empty: $asset" >&2 + exit 1 + fi +done if "$GIT_BIN" rev-parse -q --verify "refs/tags/$VERSION" >/dev/null; then if [[ "$("$GIT_BIN" rev-parse "${VERSION}^{commit}")" != "$HEAD" ]]; then @@ -62,12 +64,16 @@ fi if "$GH_BIN" release view "$VERSION" --repo "$REPOSITORY" >/dev/null 2>&1; then "$GH_BIN" release upload "$VERSION" "${ASSETS[@]}" --repo "$REPOSITORY" --clobber else + RELEASE_OPTIONS=(--generate-notes --verify-tag) + if [[ "$VERSION" == *-* ]]; then + RELEASE_OPTIONS+=(--prerelease) + else + RELEASE_OPTIONS+=(--latest) + fi "$GH_BIN" release create "$VERSION" "${ASSETS[@]}" \ --repo "$REPOSITORY" \ --title "Verstak Official Plugins $VERSION" \ - --generate-notes \ - --latest \ - --verify-tag + "${RELEASE_OPTIONS[@]}" fi echo "GitHub release:" diff --git a/scripts/release.sh b/scripts/release.sh index 5a94b3e..488fe85 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -12,18 +12,4 @@ fi echo "=== verstak official plugins release $VERSION ===" "$ROOT/scripts/check.sh" -"$ROOT/scripts/build.sh" - -RELEASE_ROOT="$ROOT/release" -STAGING="$RELEASE_ROOT/verstak-official-plugins-$VERSION" -ARCHIVE="$RELEASE_ROOT/verstak-official-plugins-$VERSION.tar.gz" -rm -rf "$STAGING" "$ARCHIVE" -mkdir -p "$STAGING" - -cp "$ROOT/README.md" "$ROOT/LICENSE" "$STAGING/" -cp -R "$ROOT/dist" "$STAGING/dist" -tar -C "$RELEASE_ROOT" -czf "$ARCHIVE" "$(basename "$STAGING")" -(cd "$RELEASE_ROOT" && sha256sum "$(basename "$ARCHIVE")" > SHA256SUMS) - -echo "release archive: $ARCHIVE" -echo "checksums: $RELEASE_ROOT/SHA256SUMS" +"$ROOT/scripts/package-portable.sh" "$VERSION" diff --git a/scripts/test-package-portable.sh b/scripts/test-package-portable.sh index dd5d3f7..2861ba0 100755 --- a/scripts/test-package-portable.sh +++ b/scripts/test-package-portable.sh @@ -17,5 +17,6 @@ grep -Fq 'verstak-official-plugins-windows-amd64-' "$PACKAGER" grep -Fq 'tar -C' "$PACKAGER" grep -Fq 'zip -qr' "$PACKAGER" grep -Fq 'SHA256SUMS' "$PACKAGER" +grep -Fq 'package-portable.sh' "$ROOT/scripts/release.sh" echo "portable plugin package script contract passed" diff --git a/scripts/test-publish-github-release.sh b/scripts/test-publish-github-release.sh index 25dda23..ab2acd5 100755 --- a/scripts/test-publish-github-release.sh +++ b/scripts/test-publish-github-release.sh @@ -5,7 +5,10 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd)" PUBLISHER="$ROOT/scripts/publish-github-release.sh" VERSION="v0.0.0-test" REPOSITORY="mirivlad/verstak-official-plugins" -ASSET_NAME="verstak-official-plugins-${VERSION}.tar.gz" +ASSET_NAMES=( + "verstak-official-plugins-linux-amd64-v0.0.0-test.tar.gz" + "verstak-official-plugins-windows-amd64-v0.0.0-test.zip" +) WORK="$(mktemp -d)" trap 'rm -rf "$WORK"' EXIT @@ -22,7 +25,8 @@ cat > "$WORK/release.sh" <<'SCRIPT' #!/usr/bin/env bash set -euo pipefail printf 'release:%s\n' "$1" >> "$LOG" -printf 'archive\n' > "$VERSTAK_RELEASE_DIR/verstak-official-plugins-$1.tar.gz" +printf 'linux\n' > "$VERSTAK_RELEASE_DIR/verstak-official-plugins-linux-amd64-$1.tar.gz" +printf 'windows\n' > "$VERSTAK_RELEASE_DIR/verstak-official-plugins-windows-amd64-$1.zip" printf 'checksum\n' > "$VERSTAK_RELEASE_DIR/SHA256SUMS" SCRIPT chmod +x "$WORK/release.sh" @@ -82,8 +86,11 @@ grep -Fqx "release:$VERSION" "$LOG" grep -Fqx "tag:$VERSION" "$LOG" grep -Fqx "push:origin:refs/tags/$VERSION" "$LOG" grep -F "release create $VERSION" "$LOG" >/dev/null -grep -F "$ASSET_NAME" "$LOG" >/dev/null +for asset in "${ASSET_NAMES[@]}"; do + grep -F "$asset" "$LOG" >/dev/null +done grep -F "SHA256SUMS" "$LOG" >/dev/null +grep -F -- "--prerelease" "$LOG" >/dev/null run_publisher grep -F "release upload $VERSION" "$LOG" >/dev/null