mirror of
https://gitlab.com/fscarmen/warp.git
synced 2026-06-15 03:25:42 +08:00
fix: correct regex pattern for extracting local version number.
Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
+47
-20
@@ -1,6 +1,6 @@
|
||||
stages:
|
||||
- Synchronize applications # 变量 job: sync 时手动运行,all 时运行所有
|
||||
- Mirror to others git repositories # 变量 job: mirror 时手动运行,all 时运行所有
|
||||
- Synchronize applications # 变量 job: sync 时手动运行,all 时运行所有
|
||||
- Mirror to others git repositories # 变量 job: mirror 时手动运行,all 时运行所有
|
||||
|
||||
Synchronize applications:
|
||||
stage: Synchronize applications
|
||||
@@ -30,13 +30,17 @@ Synchronize applications:
|
||||
|
||||
- echo "Synchronize wgcf"
|
||||
- |
|
||||
WGCF_NOW=$(wget -qO- https://gitlab.com/$CI_PROJECT_PATH/-/raw/main/docker.sh | grep 'latest=${latest' | cut -d \' -f2)
|
||||
set -euo pipefail # 快速失败处理
|
||||
WGCF_VERSION="" # 初始化变量,防 unbound (修复主要问题)
|
||||
WGCF_NOW=$(wget -qO- https://gitlab.com/$CI_PROJECT_PATH/-/raw/main/docker.sh | awk -F'[:}-]' '/latest=\${latest/ {gsub(/[ \t'\'']/,"",$3); print $3; exit}')
|
||||
WGCF_LATEST=$(wget -qO- "https://api.github.com/repos/ViRb3/wgcf/releases/latest" | awk -F [v\"] '/tag_name/{print $5}')
|
||||
|
||||
# 可选调试:echo "WGCF_NOW: '$WGCF_NOW'" ; echo "WGCF_LATEST: '$WGCF_LATEST'"
|
||||
|
||||
if [ "$WGCF_LATEST" != "$WGCF_NOW" ]; then
|
||||
[ ! -d $WGCF_DIR ] && mkdir -p $WGCF_DIR
|
||||
PLATFORM=("darwin_amd64" "darwin_arm64" "linux_386" "linux_amd64" "linux_arm64" "linux_386" "linux_s390x" "windows_386.exe" "windows_amd64.exe")
|
||||
SCRIPTS=("docker.sh" "menu.sh" "pc/mac.sh")
|
||||
SCRIPTS=("docker.sh" "pc/mac.sh")
|
||||
|
||||
for i in "${PLATFORM[@]}"; do
|
||||
wget -NP $WGCF_DIR/ https://github.com/ViRb3/wgcf/releases/download/v"$WGCF_LATEST"/wgcf_"$WGCF_LATEST"_"$i"
|
||||
@@ -44,21 +48,29 @@ Synchronize applications:
|
||||
done
|
||||
|
||||
for j in "${SCRIPTS[@]}"; do
|
||||
sed -Ei "s/(wgcf.*|[[:space:]]+latest.*)$WGCF_NOW/\1$WGCF_LATEST/g" $j || true
|
||||
sed -Ei "s/(wgcf.*|[ \t]+latest.*)$WGCF_NOW/\1$WGCF_LATEST/g" $j || true
|
||||
done
|
||||
|
||||
export WGCF_VERSION="$WGCF_LATEST"
|
||||
fi
|
||||
|
||||
if [ -n "$WGCF_VERSION" ]; then
|
||||
git add .
|
||||
git commit -m "Sync wgcf to V$WGCF_VERSION by GitLab CI/CD, $CI_JOB_STARTED_AT"
|
||||
if git diff --quiet; then
|
||||
echo "No changes to commit for wgcf."
|
||||
else
|
||||
git add .
|
||||
git commit -m "Sync wgcf to V$WGCF_VERSION by GitLab CI/CD, $CI_JOB_STARTED_AT"
|
||||
fi
|
||||
fi
|
||||
|
||||
- echo "Synchronize warp-go"
|
||||
- |
|
||||
WARP_GO_NOW=$(wget -qO- https://gitlab.com/$CI_PROJECT_PATH/-/raw/main/warp-go.sh | grep 'latest=${latest' | cut -d \' -f2)
|
||||
WARP_GO_LATEST=$(wget -qO- -T1 -t1 https://gitlab.com/api/v4/projects/ProjectWARP%2Fwarp-go/releases | grep -oP '"tag_name":"v\K[^\"]+' | head -n 1)
|
||||
set -euo pipefail # 快速失败处理
|
||||
WARP_GO_VERSION="" # 初始化变量,防 unbound
|
||||
WARP_GO_NOW=$(wget -qO- https://gitlab.com/$CI_PROJECT_PATH/-/raw/main/warp-go.sh | awk -F'[:}-]' '/latest=\${latest/ {gsub(/[ \t'\'']/,"",$3); print $3; exit}')
|
||||
WARP_GO_LATEST=$(wget -qO- -T1 -t1 https://gitlab.com/api/v4/projects/ProjectWARP%2Fwarp-go/releases | grep -oP '"tag_name":"v\K[^\"]+' | head -n 1 | sed 's/^[ \t]*//;s/[ \t]*$//')
|
||||
|
||||
# 可选调试:echo "WARP_GO_NOW: '$WARP_GO_NOW'" ; echo "WARP_GO_LATEST: '$WARP_GO_LATEST'"
|
||||
|
||||
if [ "$WARP_GO_LATEST" != "$WARP_GO_NOW" ]; then
|
||||
[ ! -d $WARP_GO_DIR ] && mkdir -p $WARP_GO_DIR
|
||||
@@ -71,27 +83,35 @@ Synchronize applications:
|
||||
done
|
||||
|
||||
for j in "${SCRIPTS[@]}"; do
|
||||
sed -Ei "s/(warp-go.*|latest.*)$WARP_GO_NOW/\1$WARP_GO_LATEST/g" $j || true
|
||||
sed -Ei "s/(warp-go.*|[ \t]+latest.*)$WARP_GO_NOW/\1$WARP_GO_LATEST/g" $j || true
|
||||
done
|
||||
|
||||
export WARP_GO_VERSION="$WARP_GO_LATEST"
|
||||
fi
|
||||
|
||||
if [ -n "$WARP_GO_VERSION" ]; then
|
||||
git add .
|
||||
git commit -m "Sync warp-go to V$WARP_GO_VERSION by GitLab CI/CD, $CI_JOB_STARTED_AT"
|
||||
if git diff --quiet; then
|
||||
echo "No changes to commit for warp-go."
|
||||
else
|
||||
git add .
|
||||
git commit -m "Sync warp-go to V$WARP_GO_VERSION by GitLab CI/CD, $CI_JOB_STARTED_AT"
|
||||
fi
|
||||
fi
|
||||
|
||||
- echo "Synchronize wireproxy"
|
||||
- |
|
||||
WIREPROXY_NOW=$(wget -qO- https://gitlab.com/$CI_PROJECT_PATH/-/raw/main/wireproxy/version_history | head -n 1 | sed "s/.*v\(.*\)/\1/g")
|
||||
WIREPROXY_LATEST=$(wget -qO- "https://api.github.com/repos/octeep/wireproxy/releases/latest" | grep "tag_name" | head -n 1 | cut -d : -f2 | sed 's/[ \"v,]//g')
|
||||
set -euo pipefail # 快速失败处理
|
||||
WIREPROXY_VERSION="" # 初始化变量,防 unbound
|
||||
WIREPROXY_NOW=$(wget -qO- https://gitlab.com/$CI_PROJECT_PATH/-/raw/main/wireproxy/version_history | head -n 1 | sed "s/.*v\(.*\)/\1/g" | sed 's/^[ \t]*//;s/[ \t]*$//')
|
||||
WIREPROXY_LATEST=$(wget -qO- "https://api.github.com/repos/octeep/wireproxy/releases/latest" | grep "tag_name" | head -n 1 | cut -d : -f2 | sed 's/[ \"v,]//g' | sed 's/^[ \t]*//;s/[ \t]*$//')
|
||||
|
||||
# 可选调试:echo "WIREPROXY_NOW: '$WIREPROXY_NOW'" ; echo "WIREPROXY_LATEST: '$WIREPROXY_LATEST'"
|
||||
|
||||
if [ "$WIREPROXY_LATEST" != "$WIREPROXY_NOW" ]; then
|
||||
[ ! -d $WIREPROXY_DIR ] && mkdir -p $WIREPROXY_DIR
|
||||
PLATFORM=( "linux_amd64" "linux_arm64" "linux_s390x" )
|
||||
for i in "${PLATFORM[@]}"; do
|
||||
wget -O $WIREPROXY_DIR/wireproxy_"$i".tar.gz https://github.com/octeep/wireproxy/releases/download/v"$WIREPROXY_LATEST"/wireproxy_"$i".tar.gz
|
||||
wget -N -O $WIREPROXY_DIR/wireproxy_"$i".tar.gz https://github.com/octeep/wireproxy/releases/download/v"$WIREPROXY_LATEST"/wireproxy_"$i".tar.gz # 已 -N
|
||||
done
|
||||
sed -Ei "s/(wireproxy_latest.*)$WIREPROXY_NOW/\1$WIREPROXY_LATEST/g" menu.sh || true
|
||||
sed -i "1i$(date "+%Y/%m/%d") v$WIREPROXY_LATEST" $WIREPROXY_DIR/version_history || true
|
||||
@@ -100,13 +120,20 @@ Synchronize applications:
|
||||
fi
|
||||
|
||||
if [ -n "$WIREPROXY_VERSION" ]; then
|
||||
git add .
|
||||
git commit -m "Sync wireproxy to V$WIREPROXY_VERSION by GitLab CI/CD, $CI_JOB_STARTED_AT"
|
||||
if git diff --quiet; then
|
||||
echo "No changes to commit for wireproxy."
|
||||
else
|
||||
git add .
|
||||
git commit -m "Sync wireproxy to V$WIREPROXY_VERSION by GitLab CI/CD, $CI_JOB_STARTED_AT"
|
||||
fi
|
||||
fi
|
||||
|
||||
- echo "Push to repo"
|
||||
- |
|
||||
if [ -n "$WGCF_VERSION$WARP_GO_VERSION$WIREPROXY_VERSION" ]; then
|
||||
set -euo pipefail
|
||||
# 初始化 Push 块变量,防 unbound (额外安全)
|
||||
WGCF_VERSION="${WGCF_VERSION:-}" WARP_GO_VERSION="${WARP_GO_VERSION:-}" WIREPROXY_VERSION="${WIREPROXY_VERSION:-}"
|
||||
if [ -n "$WGCF_VERSION$WARP_GO_VERSION$WIREPROXY_VERSION" ] && ! git diff --quiet; then
|
||||
git push origin HEAD:refs/heads/main --force
|
||||
else
|
||||
echo "Nothing needs update."
|
||||
@@ -142,13 +169,13 @@ Synchronize applications:
|
||||
git remote remove mirror
|
||||
|
||||
# Mirror to Bitbucket:
|
||||
#
|
||||
#
|
||||
# variables:
|
||||
# GIT_USER_NAME: $GITLAB_USER_NAME
|
||||
# GIT_SSH_COMMAND: "ssh -v -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -l $GIT_USER_NAME"
|
||||
# GIT_REPO: Bitbucket
|
||||
# TARGET_REPO_URL: git@bitbucket.org:$CI_PROJECT_PATH.git
|
||||
#
|
||||
#
|
||||
# <<: *mirror_script
|
||||
|
||||
# Mirror to Gitlab group:
|
||||
|
||||
@@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 2024 fscarmen
|
||||
WARP & WARP-GO: The script is a convenient tool designed to simplify the process of setting up a secure and reliable WireGuard VPN connection using Cloudflare's Warp service
|
||||
Copyright (C) 2021-2025 fscarmen
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -652,11 +652,14 @@ Also add information on how to contact you by electronic and paper mail.
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) 2024 fscarmen
|
||||
WARP & WARP-GO Scripts Copyright (C) 2021-2025 fscarmen
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
menu.sh - Interactive menu for managing WARP network interfaces on VPS
|
||||
warp-go.sh - WARP network interface management using warp-go core
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
Reference in New Issue
Block a user