Skip to content

Update & Commit Hysteria (ARMv5 + UPX 3.94) #6

Update & Commit Hysteria (ARMv5 + UPX 3.94)

Update & Commit Hysteria (ARMv5 + UPX 3.94) #6

name: Update & Commit Hysteria (ARMv5 + UPX 3.94)
on:
schedule:
- cron: "5 4 * * 6" # At 04:05 on Saturday
workflow_dispatch: {}
permissions:
contents: write
jobs:
update:
runs-on: ubuntu-22.04
env:
OWNER: apernet
REPO: hysteria
DEST_DIR: 380_armv5/hysteria # <-- fixed path
ASSET_NAME: hysteria-linux-armv5
UPX_URL: https://github.com/upx/upx/releases/download/v3.94/upx-3.94-amd64_linux.tar.xz
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install system dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y curl xz-utils jq ca-certificates file
- name: Read local latest (strip leading v)
id: local
run: |
set -euo pipefail
f="${{ env.DEST_DIR }}/latest.txt"
if [[ -f "$f" ]]; then
raw="$(tr -d '\r' < "$f" | tr -d ' \n')"
ver="${raw#v}"
else
raw=""
ver="0.0.0"
fi
echo "raw_local=$raw" >> $GITHUB_OUTPUT
echo "local_num=$ver" >> $GITHUB_OUTPUT
echo "Local latest (num) = '$ver'"
- name: Resolve remote latest app/* (strip app/v, pick highest semver)
id: remote
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
json="$(curl -fsSL -H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/${OWNER}/${REPO}/releases?per_page=100")"
mapfile -t rows < <(jq -r '
.[] | select(.tag_name|startswith("app/")) as $r
| ($r.tag_name|sub("^app/v";"")) as $num
| ($r.tag_name) as $tag
| ($r.assets[]? | select(.name=="'"${ASSET_NAME}"'") | .browser_download_url) as $url
| select($url != null)
| "\($num)|\($tag)|\($url)"
' <<<"$json")
[[ ${#rows[@]} -gt 0 ]] || { echo "No app/* releases with ${ASSET_NAME}"; exit 1; }
latest_row="$(printf "%s\n" "${rows[@]}" | sort -t'|' -k1,1V | tail -n1)"
IFS='|' read -r num tag url <<<"$latest_row"
# sanity: keep only x.y.z form for compare
num_clean="$(echo "$num" | grep -oE '^[0-9]+(\.[0-9]+){1,2}')"
echo "remote_num=$num_clean" >> $GITHUB_OUTPUT
echo "remote_tag=$tag" >> $GITHUB_OUTPUT
echo "remote_url=$url" >> $GITHUB_OUTPUT
echo "Remote latest: num=$num_clean tag=$tag"
- name: Decide update (only if remote > local)
id: guard
run: |
set -euo pipefail
local_v="${{ steps.local.outputs.local_num }}"
remote_v="${{ steps.remote.outputs.remote_num }}"
if [[ -z "$remote_v" ]]; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "No remote version detected."
exit 0
fi
# if the folder for v<remote> already exists, skip
if [[ -d "${{ env.DEST_DIR }}/v${remote_v}" ]]; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "Folder already exists for v${remote_v}; skipping."
exit 0
fi
top="$(printf "%s\n%s\n" "$local_v" "$remote_v" | sort -V | tail -n1)"
if [[ "$top" == "$remote_v" && "$remote_v" != "$local_v" ]]; then
echo "skip=false" >> $GITHUB_OUTPUT
echo "Update needed: $local_v -> $remote_v"
else
echo "skip=true" >> $GITHUB_OUTPUT
echo "Already latest: local=$local_v, remote=$remote_v"
fi
- name: Stop if no update
if: steps.guard.outputs.skip == 'true'
run: echo "No update needed."
- name: Install UPX 3.94 (ucl alias)
if: steps.guard.outputs.skip == 'false'
run: |
curl -fsSL "${UPX_URL}" -o upx.tar.xz
tar -xJf upx.tar.xz
sudo mv upx-3.94-amd64_linux/upx /usr/local/bin/upx
sudo ln -sf /usr/local/bin/upx /usr/local/bin/upx-ucl
upx-ucl -V
- name: Download Hysteria ARMv5 asset (remote latest)
if: steps.guard.outputs.skip == 'false'
run: |
curl -fL "${{ steps.remote.outputs.remote_url }}" -o "${{ env.ASSET_NAME }}"
chmod +x "${{ env.ASSET_NAME }}"
file "${{ env.ASSET_NAME }}" || true
ls -lh "${{ env.ASSET_NAME }}"
- name: Compress with UPX 3.94
if: steps.guard.outputs.skip == 'false'
run: |
upx-ucl --lzma --ultra-brute "${{ env.ASSET_NAME }}" || echo "UPX failed; keeping original."
ls -lh "${{ env.ASSET_NAME }}"
- name: Place versioned binary & update latest.txt
if: steps.guard.outputs.skip == 'false'
run: |
ver="${{ steps.remote.outputs.remote_num }}" # e.g. 2.6.5
mkdir -p "${DEST_DIR}/v${ver}"
cp -f "${ASSET_NAME}" "${DEST_DIR}/v${ver}/${ASSET_NAME}"
echo "v${ver}" > "${DEST_DIR}/latest.txt" # store version like v2.6.5
- name: Commit and push (message = v<version>)
if: steps.guard.outputs.skip == 'false'
run: |
set -e
ver="${{ steps.remote.outputs.remote_num }}"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add "${DEST_DIR}/v${ver}/${ASSET_NAME}" "${DEST_DIR}/latest.txt"
git commit -m "hysteria v${ver}" || echo "No changes to commit."
git push