mirror of
https://github.com/nickrunning/wechat-selkies.git
synced 2026-05-09 00:24:09 +00:00
feat: automate upstream wechat version detection
This commit is contained in:
125
.github/scripts/detect-upstream.sh
vendored
Executable file
125
.github/scripts/detect-upstream.sh
vendored
Executable file
@@ -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" <<EOF
|
||||||
|
# Upstream package state tracked by automation.
|
||||||
|
|
||||||
|
WECHAT_AMD64_URL="$WECHAT_AMD64_URL"
|
||||||
|
WECHAT_ARM64_URL="$WECHAT_ARM64_URL"
|
||||||
|
|
||||||
|
WECHAT_AMD64_VERSION="$WECHAT_AMD64_VERSION"
|
||||||
|
WECHAT_ARM64_VERSION="$WECHAT_ARM64_VERSION"
|
||||||
|
|
||||||
|
WECHAT_AMD64_SHA256="$WECHAT_AMD64_SHA256"
|
||||||
|
WECHAT_ARM64_SHA256="$WECHAT_ARM64_SHA256"
|
||||||
|
|
||||||
|
WECHAT_LAST_CHECKED_AT="$WECHAT_LAST_CHECKED_AT"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "$STATE_FILE")"
|
||||||
|
if [[ ! -f "$STATE_FILE" ]] || ! cmp -s "$NEW_STATE_FILE" "$STATE_FILE"; then
|
||||||
|
cp "$NEW_STATE_FILE" "$STATE_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Change detected: $CHANGE_DETECTED"
|
||||||
|
echo "WECHAT_AMD64_VERSION=$WECHAT_AMD64_VERSION"
|
||||||
|
echo "WECHAT_ARM64_VERSION=$WECHAT_ARM64_VERSION"
|
||||||
|
|
||||||
|
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
|
||||||
|
{
|
||||||
|
echo "changed=$CHANGE_DETECTED"
|
||||||
|
echo "wechat_amd64_version=$WECHAT_AMD64_VERSION"
|
||||||
|
echo "wechat_arm64_version=$WECHAT_ARM64_VERSION"
|
||||||
|
echo "state_file=$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
|
||||||
32
.github/workflows/detect-upstream.yml
vendored
Normal file
32
.github/workflows/detect-upstream.yml
vendored
Normal file
@@ -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
|
||||||
4
.github/workflows/docker.yml
vendored
4
.github/workflows/docker.yml
vendored
@@ -3,6 +3,10 @@ name: Build and Publish Docker Image
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- 'versions/upstream.env'
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
|
||||||
|
|||||||
15
README.md
15
README.md
@@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
> 如果升级后部分功能缺失,请先清空本地挂载目录下的openbox目录(如`./config/.config/openbox`)。
|
> 如果升级后部分功能缺失,请先清空本地挂载目录下的openbox目录(如`./config/.config/openbox`)。
|
||||||
|
|
||||||
|
> 仓库内置了上游微信版本自动检测机制:GitHub Actions 会定时检查官方 `.deb` 包版本,检测到变化后自动更新 `versions/upstream.env` 并触发镜像构建。
|
||||||
|
|
||||||
## 功能特性
|
## 功能特性
|
||||||
|
|
||||||
- 🌐 **浏览器访问**:通过 Web 浏览器直接使用微信,无需本地安装
|
- 🌐 **浏览器访问**:通过 Web 浏览器直接使用微信,无需本地安装
|
||||||
@@ -244,6 +246,19 @@ git pull && docker compose up -d --build
|
|||||||
|
|
||||||
> **注意:** 微信和QQ的安装包 URL 指向官方最新版本,重新构建镜像时会自动下载最新版。
|
> **注意:** 微信和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**
|
1. **无法访问 Web UI**
|
||||||
|
|||||||
15
README_en.md
15
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`).
|
> 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
|
## Features
|
||||||
|
|
||||||
- 🌐 **Browser Access**: Use WeChat directly through web browsers without local installation
|
- 🌐 **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.
|
> **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
|
### Common Issues
|
||||||
|
|
||||||
1. **Unable to access Web UI**
|
1. **Unable to access Web UI**
|
||||||
|
|||||||
12
versions/upstream.env
Normal file
12
versions/upstream.env
Normal file
@@ -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=""
|
||||||
Reference in New Issue
Block a user