From a5f832dd091fa25881b98f492514d070fad9dc67 Mon Sep 17 00:00:00 2001 From: Nick007 Date: Tue, 7 Apr 2026 17:35:47 +0800 Subject: [PATCH] feat: automate upstream wechat version detection --- .github/scripts/detect-upstream.sh | 125 ++++++++++++++++++++++++++ .github/workflows/detect-upstream.yml | 32 +++++++ .github/workflows/docker.yml | 6 +- README.md | 17 +++- README_en.md | 17 +++- versions/upstream.env | 12 +++ 6 files changed, 206 insertions(+), 3 deletions(-) create mode 100755 .github/scripts/detect-upstream.sh create mode 100644 .github/workflows/detect-upstream.yml create mode 100644 versions/upstream.env diff --git a/.github/scripts/detect-upstream.sh b/.github/scripts/detect-upstream.sh new file mode 100755 index 0000000..f77713b --- /dev/null +++ b/.github/scripts/detect-upstream.sh @@ -0,0 +1,125 @@ +#!/usr/bin/env bash + +set -euo pipefail + +STATE_FILE="${STATE_FILE:-versions/upstream.env}" +TMP_DIR="$(mktemp -d)" +CHANGE_DETECTED="false" +ENV_WECHAT_AMD64_URL="${WECHAT_AMD64_URL-__UNSET__}" +ENV_WECHAT_ARM64_URL="${WECHAT_ARM64_URL-__UNSET__}" + +cleanup() { + rm -rf "$TMP_DIR" +} + +trap cleanup EXIT + +if [[ -f "$STATE_FILE" ]]; then + # shellcheck disable=SC1090 + source "$STATE_FILE" +fi + +if [[ "$ENV_WECHAT_AMD64_URL" != "__UNSET__" ]]; then + WECHAT_AMD64_URL="$ENV_WECHAT_AMD64_URL" +fi + +if [[ "$ENV_WECHAT_ARM64_URL" != "__UNSET__" ]]; then + WECHAT_ARM64_URL="$ENV_WECHAT_ARM64_URL" +fi + +WECHAT_AMD64_URL="${WECHAT_AMD64_URL:-https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_x86_64.deb}" +WECHAT_ARM64_URL="${WECHAT_ARM64_URL:-https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_arm64.deb}" + +download_package() { + local source_path="$1" + local destination="$2" + + case "$source_path" in + http://*|https://*) + curl --fail --silent --show-error --location \ + --retry 3 --retry-delay 5 --retry-all-errors \ + -o "$destination" "$source_path" + ;; + *) + cp "$source_path" "$destination" + ;; + esac +} + +read_metadata() { + local package_name="$1" + local arch="$2" + local source_path="$3" + local package_path="$TMP_DIR/${package_name}-${arch}.deb" + local version_var="${package_name}_${arch}_VERSION" + local sha_var="${package_name}_${arch}_SHA256" + local current_version="${!version_var:-}" + local current_sha="${!sha_var:-}" + local detected_version + local detected_sha + + echo "Checking ${package_name} ${arch} from ${source_path}" + download_package "$source_path" "$package_path" + + detected_version="$(dpkg-deb -f "$package_path" Version)" + detected_sha="$(sha256sum "$package_path" | awk '{print $1}')" + + printf -v "$version_var" '%s' "$detected_version" + printf -v "$sha_var" '%s' "$detected_sha" + + if [[ "$current_version" != "$detected_version" || "$current_sha" != "$detected_sha" ]]; then + CHANGE_DETECTED="true" + fi +} + +read_metadata "WECHAT" "AMD64" "$WECHAT_AMD64_URL" +read_metadata "WECHAT" "ARM64" "$WECHAT_ARM64_URL" + +if [[ "$CHANGE_DETECTED" == "true" || ! -f "$STATE_FILE" ]]; then + WECHAT_LAST_CHECKED_AT="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" +fi + +NEW_STATE_FILE="$TMP_DIR/upstream.env" +cat > "$NEW_STATE_FILE" <> "$GITHUB_OUTPUT" +fi + +if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then + { + echo "## Upstream Detection" + echo "" + echo "- Changed: \`$CHANGE_DETECTED\`" + echo "- WeChat amd64: \`$WECHAT_AMD64_VERSION\`" + echo "- WeChat arm64: \`$WECHAT_ARM64_VERSION\`" + echo "- State file: \`$STATE_FILE\`" + } >> "$GITHUB_STEP_SUMMARY" +fi diff --git a/.github/workflows/detect-upstream.yml b/.github/workflows/detect-upstream.yml new file mode 100644 index 0000000..d5f3a37 --- /dev/null +++ b/.github/workflows/detect-upstream.yml @@ -0,0 +1,32 @@ +name: Detect Upstream Package Updates + +on: + workflow_dispatch: + schedule: + - cron: '23 */6 * * *' + +permissions: + contents: write + +jobs: + detect-wechat-updates: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Detect upstream package changes + id: detect + run: ./.github/scripts/detect-upstream.sh + + - name: Commit updated version state + if: steps.detect.outputs.changed == 'true' + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add versions/upstream.env + git commit -m "chore: update upstream package state" + git push diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c294f77..c809658 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,6 +3,10 @@ name: Build and Publish Docker Image on: workflow_dispatch: push: + branches: + - master + paths: + - 'versions/upstream.env' tags: - 'v*' @@ -180,4 +184,4 @@ jobs: docker run -it -p 3001:3001 -v ./config:/config --device /dev/dri:/dev/dri ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:minimal ``` - Then visit: https://localhost:3001 \ No newline at end of file + Then visit: https://localhost:3001 diff --git a/README.md b/README.md index 153f6a4..3291f19 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ > 如果升级后部分功能缺失,请先清空本地挂载目录下的openbox目录(如`./config/.config/openbox`)。 +> 仓库内置了上游微信版本自动检测机制:GitHub Actions 会定时检查官方 `.deb` 包版本,检测到变化后自动更新 `versions/upstream.env` 并触发镜像构建。 + ## 功能特性 - 🌐 **浏览器访问**:通过 Web 浏览器直接使用微信,无需本地安装 @@ -244,6 +246,19 @@ git pull && docker compose up -d --build > **注意:** 微信和QQ的安装包 URL 指向官方最新版本,重新构建镜像时会自动下载最新版。 +对于仓库维护者,当前自动化流程如下: + +1. `Detect Upstream Package Updates` 每 6 小时检查一次微信官方安装包版本,也支持手动触发 +2. 如果检测到版本号或安装包哈希变化,工作流会更新 `versions/upstream.env` +3. 该文件变更提交到 `master` 后,会自动触发 `Build and Publish Docker Image` + +版本状态文件位于 `versions/upstream.env`,当前记录了: + +- 微信 amd64/arm64 下载地址 +- 微信 amd64/arm64 解析出的版本号 +- 微信 amd64/arm64 安装包 SHA256 +- 最近一次发生变更的检测时间 + ### 常见问题 1. **无法访问 Web UI** @@ -321,4 +336,4 @@ docker compose logs -f wechat-selkies ## Star History -[![Star History Chart](https://api.star-history.com/svg?repos=nickrunning/wechat-selkies&type=Date)](https://www.star-history.com/#nickrunning/wechat-selkies&Date) \ No newline at end of file +[![Star History Chart](https://api.star-history.com/svg?repos=nickrunning/wechat-selkies&type=Date)](https://www.star-history.com/#nickrunning/wechat-selkies&Date) diff --git a/README_en.md b/README_en.md index dbf1621..982e096 100644 --- a/README_en.md +++ b/README_en.md @@ -22,6 +22,8 @@ This project packages the official WeChat/QQ Linux client in a Docker container, > If some features are missing after an upgrade, please clear the `openbox` directory in the local mounted directory (e.g., `./config/.config/openbox`). +> This repository includes automatic upstream WeChat version detection: GitHub Actions periodically checks the official `.deb` packages, updates `versions/upstream.env` when changes are detected, and then triggers the image build workflow. + ## Features - 🌐 **Browser Access**: Use WeChat directly through web browsers without local installation @@ -243,6 +245,19 @@ git pull && docker compose up -d --build > **Note:** The WeChat and QQ download URLs point to the latest official versions. Rebuilding the image will automatically download the newest version. +For maintainers, the current automation flow is: + +1. `Detect Upstream Package Updates` checks the official WeChat packages every 6 hours and can also be triggered manually +2. If the version or package hash changes, the workflow updates `versions/upstream.env` +3. Once that file is committed to `master`, it automatically triggers `Build and Publish Docker Image` + +The version state file is stored at `versions/upstream.env` and currently records: + +- WeChat amd64/arm64 download URLs +- Parsed WeChat amd64/arm64 package versions +- WeChat amd64/arm64 package SHA256 hashes +- The last detection time that actually changed the tracked state + ### Common Issues 1. **Unable to access Web UI** @@ -320,4 +335,4 @@ This project is licensed under **MIT License**. See the [LICENSE](LICENSE) file ## Star History -[![Star History Chart](https://api.star-history.com/svg?repos=nickrunning/wechat-selkies&type=Date)](https://www.star-history.com/#nickrunning/wechat-selkies&Date) \ No newline at end of file +[![Star History Chart](https://api.star-history.com/svg?repos=nickrunning/wechat-selkies&type=Date)](https://www.star-history.com/#nickrunning/wechat-selkies&Date) diff --git a/versions/upstream.env b/versions/upstream.env new file mode 100644 index 0000000..364c010 --- /dev/null +++ b/versions/upstream.env @@ -0,0 +1,12 @@ +# Upstream package state tracked by automation. + +WECHAT_AMD64_URL="https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_x86_64.deb" +WECHAT_ARM64_URL="https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_arm64.deb" + +WECHAT_AMD64_VERSION="" +WECHAT_ARM64_VERSION="" + +WECHAT_AMD64_SHA256="" +WECHAT_ARM64_SHA256="" + +WECHAT_LAST_CHECKED_AT=""