Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
needs: [check, package]
if: needs.check.outputs.exists == 'false'
runs-on: ubuntu-latest
timeout-minutes: 5
timeout-minutes: 10
permissions:
contents: write
steps:
Expand All @@ -79,6 +79,9 @@ jobs:
env:
LITHE_EXPECT_ALL_ARCHIVES: "1"
run: node --test --test-timeout=60000 scripts/package/*.test.mjs
- name: Set up optional delta generation
continue-on-error: true
run: command -v zstd || sudo apt-get install -y zstd
- name: Publish GitHub Release
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -93,6 +96,19 @@ jobs:
break
fi
done
if (( ${#release_flags[@]} == 0 )); then
if curl --fail --silent --show-error --location --proto '=https' --proto-redir '=https' \
--max-time 20 --max-filesize 5242880 \
-o "$RUNNER_TEMP/store-index.json" \
https://raw.githubusercontent.com/Lithe-IDEA/Lithe-store/HEAD/lithe-plugin-index.json &&
bash scripts/package/release-deltas.sh "$RUNNER_TEMP/store-index.json" dist "${GITHUB_REF_NAME#v}"; then
echo "Checked for optional plugin deltas."
else
echo "::warning::Could not prepare optional patches; publishing full ZIPs."
fi
fi
shopt -s nullglob
patches=(dist/*.zip.zst)
notes="docs/releases/$GITHUB_REF_NAME.md"
test -s "$notes"
{
Expand Down Expand Up @@ -122,4 +138,4 @@ jobs:
echo "::error::Release tag $GITHUB_REF_NAME no longer points to the packaged commit. Use the run for the current tag."
exit 1
fi
gh release create "$GITHUB_REF_NAME" dist/*.zip --verify-tag --title "Python Support $GITHUB_REF_NAME" --notes-file "$RUNNER_TEMP/notes.md" "${release_flags[@]}"
gh release create "$GITHUB_REF_NAME" dist/*.zip "${patches[@]}" --verify-tag --title "Python Support $GITHUB_REF_NAME" --notes-file "$RUNNER_TEMP/notes.md" "${release_flags[@]}"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ PYTEST_PYTHON=/path/to/python3.12 node scripts/e2e-host.mjs --run '^TestPythonSu
1. 修改 `io.github.lithe-idea.python-support/plugin.json` 的 `version`:修复升修订号,加功能升次版本号,特别大的革新才升主版本号。
依赖还没发布的宿主能力时照样升次版本号,作为预发布版本发布。写好 `docs/releases/v<版本>.md`,合入 `main`。
2. 推送同名标签,例如 `git tag v1.2.0 && git push origin v1.2.0`。
3. `Release` 工作流核对标签与版本,打六个平台的包并发布 Release,说明里附 SHA-256 和 `docs/releases/v<版本>.md`。
3. `Release` 工作流核对标签与版本,打六个平台的包并发布 Release,说明里附 SHA-256 和 `docs/releases/v<版本>.md`。 正式发布还会对照 Lithe Store 的上一个同平台版本生成可选增量包。校验成功、且补丁最多为完整包的 75% 时才随 Release 发布。
`release.yml` 的 `PRERELEASE_TAGS` 里的版本标为预发布,目前是 `v0.1.0`、`v0.1.1` 和 `v1.2.0`。
4. Lithe Store 的自动追踪会为稳定版本开合并请求,合并后用户即可更新。

Expand Down
66 changes: 66 additions & 0 deletions scripts/package/release-deltas.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash
# Packages optional patches from the newest Store-listed release per platform.
set -euo pipefail

if [[ $# -ne 3 ]]; then
printf 'usage: %s STORE_INDEX ZIP_DIRECTORY TARGET_VERSION\n' "$0" >&2
exit 2
fi
index=$1
dist=$2
version=$3
plugin_id=io.github.lithe-idea.python-support
max_zip=67108864
version_pattern='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$'
[[ "$version" =~ $version_pattern ]]

scratch=$(mktemp -d)
trap 'python3 -c "import shutil, sys; shutil.rmtree(sys.argv[1])" "$scratch"' EXIT

shopt -s nullglob
for target in "$dist"/python-support-"$version"-*.zip; do
platform=${target##*/python-support-"$version"-}
platform=${platform%.zip}
[[ "$platform" =~ ^(darwin|linux|windows)-(arm64|x64)$ ]] || continue
size=$(wc -c < "$target")
(( size > 0 && size <= max_zip )) || continue

# The index is already ordered newest first. Compare the numeric parts to
# ignore a concurrent newer release and release reruns.
base=$(jq -r --arg id "$plugin_id" --arg platform "$platform" --arg target "$version" '
def semver: split(".") | map(tonumber);
first(
.plugins[] | select(.id == $id) | .versions[]
| select((.version | semver) < ($target | semver))
| .version as $version
| .downloads[] | select(.platforms | index($platform))
| [$version, .downloadURL, .sha256] | @tsv
) // empty
' "$index")
[[ -n "$base" ]] || continue
IFS=$'\t' read -r previous url digest <<< "$base"
if [[ ! "$previous" =~ $version_pattern ||
! "$url" =~ ^https://github\.com/Lithe-IDEA/lithe-plugin-python/releases/download/[^/]+/[^/]+\.zip$ ||
! "$digest" =~ ^[a-f0-9]{64}$ ]]; then
printf 'Skipping delta for %s: invalid Store archive identity.\n' "$platform" >&2
continue
fi
if ! curl --fail --silent --show-error --location --proto '=https' --proto-redir '=https' \
--max-time 25 --max-filesize "$max_zip" -o "$scratch/base.zip" "$url" ||
! actual=$(sha256sum "$scratch/base.zip") || [[ "${actual%% *}" != "$digest" ]]; then
printf 'Skipping delta for %s: Store base could not be verified.\n' "$platform" >&2
continue
fi

patch="$scratch/patch.zst"
if ! zstd -f -q -M128MB --patch-from="$scratch/base.zip" -o "$patch" -- "$target"; then
printf 'Skipping delta for %s: compression failed.\n' "$platform" >&2
continue
fi
(( $(wc -c < "$patch") <= size * 3 / 4 )) || continue
if ! zstd -q -dc -M128MB --patch-from="$scratch/base.zip" -- "$patch" | cmp -s "$target" -; then
printf 'Skipping delta for %s: reconstruction did not match target.\n' "$platform" >&2
continue
fi
mv "$patch" "${target%.zip}.from-$previous.zip.zst"
done
Loading