Compare commits

..
5 Commits
Author SHA1 Message Date
viaeon a3a199ff0e ci: 用 git clone 替代 actions/checkout(golang 镜像无 node)
CI and Docker Build / Build Binaries (push) Successful in 47s
CI and Docker Build / Build and Push Docker Images (push) Successful in 49s
CI and Docker Build / Deploy to Remote Server (push) Successful in 23s
2026-10-30 16:19:16 +08:00
viaeon 79866f7795 ci: 迁移 CI 到 Gitea Actions,构建推送 nps/npc 镜像
CI and Docker Build / Build Binaries (push) Failing after 14s
CI and Docker Build / Build and Push Docker Images (push) Skipped
CI and Docker Build / Deploy to Remote Server (push) Skipped
2026-10-30 15:53:35 +08:00
yisier 495acc683a Update sponsorship section in README.md 2026-10-27 13:50:54 +08:00
yisier 35b2054d84 Merge pull request #364 from Bald-guy69/master
fix: receiveWindowQueue.Pop busy loop when a mux conn is closed while reading
2026-10-26 17:01:02 +08:00
Bald-gyu69 19eba0c05d fix: stop receiveWindowQueue.Pop spinning forever after a concurrent release 2026-10-23 00:01:09 +08:00
7 changed files with 195 additions and 405 deletions
+140
View File
@@ -0,0 +1,140 @@
name: CI and Docker Build
on:
push:
branches:
- main
- master
tags:
- 'v*'
pull_request:
branches:
- main
- master
jobs:
build:
name: Build Binaries
runs-on: ubuntu
container:
image: golang:1.24
env:
# actions/checkout 是 JS action,需要 node,golang 镜像里没有,所以直接用 git clone
GOPROXY: https://goproxy.cn,direct
steps:
- name: Checkout repository
run: |
rm -rf /tmp/repo
git clone https://admin:${{ secrets.TOKEN }}@git.viaeon.com/admin/nps.git /tmp/repo
cd /tmp/repo
git checkout ${{ github.sha }} || true
git log --oneline -1
- name: Build nps and npc
run: |
cd /tmp/repo
go mod download
echo "Building nps..."
CGO_ENABLED=0 go build -v -o /tmp/nps ./cmd/nps/nps.go
echo "Building npc..."
CGO_ENABLED=0 go build -v -o /tmp/npc ./cmd/npc/npc.go
ls -la /tmp/nps /tmp/npc
docker:
name: Build and Push Docker Images
runs-on: ubuntu
needs: [build]
if: github.event_name == 'push'
env:
RUNNER_TOOL_CACHE: /toolcache
steps:
- name: Install Docker CLI
run: |
if ! command -v docker &> /dev/null; then
if command -v apk &> /dev/null; then
apk add --no-cache docker-cli
elif command -v apt-get &> /dev/null; then
apt-get update && apt-get install -y docker.io
else
curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz | tar xz -C /tmp
mv /tmp/docker/docker /usr/local/bin/
chmod +x /usr/local/bin/docker
fi
fi
docker --version
- name: Checkout repository
run: |
rm -rf /tmp/repo
git clone https://admin:${{ secrets.TOKEN }}@git.viaeon.com/admin/nps.git /tmp/repo
cd /tmp/repo
git checkout ${{ github.ref_name }} || true
git log --oneline -1
- name: Login to Gitea Container Registry
run: |
echo "${{ secrets.TOKEN }}" | docker login git.viaeon.com -u "${{ github.actor }}" --password-stdin 2>&1
- name: Build and push nps
run: |
cd /tmp/repo
docker build \
--label "org.opencontainers.image.source=https://git.viaeon.com/admin/nps" \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--build-arg GOPROXY=https://goproxy.cn,direct \
-f Dockerfile.nps \
-t git.viaeon.com/admin/nps:${{ github.ref_name }} \
-t git.viaeon.com/admin/nps:latest . 2>&1
docker push git.viaeon.com/admin/nps:${{ github.ref_name }} 2>&1
docker push git.viaeon.com/admin/nps:latest 2>&1
- name: Build and push npc
run: |
cd /tmp/repo
docker build \
--label "org.opencontainers.image.source=https://git.viaeon.com/admin/nps" \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--build-arg GOPROXY=https://goproxy.cn,direct \
-f Dockerfile.npc \
-t git.viaeon.com/admin/npc:${{ github.ref_name }} \
-t git.viaeon.com/admin/npc:latest . 2>&1
docker push git.viaeon.com/admin/npc:${{ github.ref_name }} 2>&1
docker push git.viaeon.com/admin/npc:latest 2>&1
deploy:
name: Deploy to Remote Server
runs-on: ubuntu
needs: docker
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Install SSH Client
run: |
if command -v apk &> /dev/null; then
apk add --no-cache openssh-client sshpass
elif command -v apt-get &> /dev/null; then
apt-get update && apt-get install -y openssh-client sshpass
else
echo "Cannot install sshpass"
exit 1
fi
ssh -V
- name: Deploy via SSH
run: |
sshpass -p '${{ secrets.DEPLOY_PASSWORD }}' ssh -o StrictHostKeyChecking=no -p ${{ secrets.DEPLOY_PORT || '22' }} ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << ENDSSH
set -e
cd "${{ secrets.DEPLOY_PATH }}"
echo "Current directory: \$(pwd)"
ls -la
echo "Pulling latest image..."
docker pull git.viaeon.com/admin/nps:latest
echo "Restarting containers..."
docker compose down || true
docker compose up -d
echo "Cleaning up old images..."
docker image prune -f
echo "Deployment completed!"
ENDSSH
-60
View File
@@ -1,60 +0,0 @@
name: Deploy Docs to GitHub Pages
on:
push:
branches: [master]
paths:
- 'docs/**'
- '.github/workflows/docs.yml'
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
# 并发:同一时刻只允许一次部署,新的提交会取消上一个未完成的运行
concurrency:
group: pages
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # lastUpdated 需要完整 git 历史
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install dependencies
working-directory: docs
run: npm install --legacy-peer-deps
- name: Build VuePress site
working-directory: docs
run: npm run docs:build
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vuepress/dist
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
-344
View File
@@ -1,344 +0,0 @@
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
env:
GUI_DIR: cmd/npc/npc-gui
FRONTEND_DIR: cmd/npc/npc-gui/frontend
WAILS_VERSION: v3.0.0-beta.12
APP_NAME: npc-gui
jobs:
# ==================== 跨平台服务端/客户端打包 ====================
build_assets:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.22"
- name: Check out code
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: |
chmod +x build.assets.sh
./build.assets.sh
- name: Upload
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
with:
files: |
freebsd_386_client.tar.gz
freebsd_386_server.tar.gz
freebsd_amd64_client.tar.gz
freebsd_amd64_server.tar.gz
freebsd_arm_client.tar.gz
freebsd_arm_server.tar.gz
linux_386_client.tar.gz
linux_386_server.tar.gz
linux_amd64_client.tar.gz
linux_amd64_server.tar.gz
linux_arm64_client.tar.gz
linux_arm64_server.tar.gz
linux_arm_v5_client.tar.gz
linux_arm_v6_client.tar.gz
linux_arm_v7_client.tar.gz
linux_arm_v5_server.tar.gz
linux_arm_v6_server.tar.gz
linux_arm_v7_server.tar.gz
linux_mips64le_client.tar.gz
linux_mips64le_server.tar.gz
linux_mips64_client.tar.gz
linux_mips64_server.tar.gz
linux_mipsle_client.tar.gz
linux_mipsle_server.tar.gz
linux_mips_client.tar.gz
linux_mips_server.tar.gz
darwin_amd64_client.tar.gz
darwin_amd64_server.tar.gz
darwin_arm64_client.tar.gz
darwin_arm64_server.tar.gz
windows_386_client.tar.gz
windows_386_server.tar.gz
windows_amd64_client.tar.gz
windows_amd64_server.tar.gz
npc_sdk.tar.gz
tag_name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ==================== Android APK ====================
build_android:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Build
run: |
chmod +x build.android.sh
docker run --rm -i -w /app -v $(pwd):/app -e ANDROID_HOME=/usr/local/android_sdk -e GOPROXY=direct fyneio/fyne-cross:android-latest /app/build.android.sh
ls -la android_client.apk
- name: Upload
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
with:
files: |
android_client.apk
tag_name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ==================== Docker 镜像 ====================
build_docker:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push nps
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile.nps
platforms: linux/amd64,linux/arm,linux/arm64
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/nps:latest
${{ secrets.DOCKERHUB_USERNAME }}/nps:${{ env.RELEASE_VERSION }}
- name: Build and push npc
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile.npc
platforms: linux/amd64,linux/arm,linux/arm64
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/npc:latest
${{ secrets.DOCKERHUB_USERNAME }}/npc:${{ env.RELEASE_VERSION }}
# ==================== Windows GUI ====================
build_windows_gui:
runs-on: windows-latest
strategy:
matrix:
include:
- platform: windows/386
os_name: windows
arch: 386
- platform: windows/amd64
os_name: windows
arch: amd64
- platform: windows/arm64
os_name: windows
arch: arm64
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: yarn
cache-dependency-path: ${{ env.FRONTEND_DIR }}/yarn.lock
- name: Enable Yarn (corepack)
run: corepack enable
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ${{ env.GUI_DIR }}/go.mod
check-latest: true
- name: Install Wails CLI
run: go install github.com/wailsapp/wails/v3/cmd/wails3@${{ env.WAILS_VERSION }}
working-directory: ${{ env.GUI_DIR }}
- name: Build and package (Windows)
shell: pwsh
working-directory: ${{ env.GUI_DIR }}
run: |
$env:GOOS = "windows"
$env:GOARCH = "${{ matrix.arch }}"
wails3 build --tags npcgui
Set-Location bin
$zipName = "$env:APP_NAME-${{ matrix.os_name }}-${{ matrix.arch }}.zip"
$exe = Get-ChildItem -Path . -Filter *.exe | Select-Object -First 1
if (-not $exe) {
Write-Host "No build output found in bin"
Get-ChildItem -Path . | Format-Table -AutoSize
exit 1
}
Compress-Archive -Path $exe.Name -DestinationPath $zipName -Force
- name: Upload Windows artifact
uses: actions/upload-artifact@v4
with:
name: windows-builds-${{ matrix.arch }}
path: ${{ env.GUI_DIR }}/bin/${{ env.APP_NAME }}-${{ matrix.os_name }}-${{ matrix.arch }}.zip
- name: Upload Windows release asset
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
with:
files: ${{ env.GUI_DIR }}/bin/${{ env.APP_NAME }}-${{ matrix.os_name }}-${{ matrix.arch }}.zip
tag_name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ==================== macOS GUI ====================
build_macos_gui:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- platform: darwin/amd64
os_name: darwin
arch: amd64
os: macos-14
- platform: darwin/arm64
os_name: darwin
arch: arm64
os: macos-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: yarn
cache-dependency-path: ${{ env.FRONTEND_DIR }}/yarn.lock
- name: Enable Yarn (corepack)
run: corepack enable
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ${{ env.GUI_DIR }}/go.mod
check-latest: true
- name: Install Wails CLI
run: go install github.com/wailsapp/wails/v3/cmd/wails3@${{ env.WAILS_VERSION }}
working-directory: ${{ env.GUI_DIR }}
- name: Build and package (macOS)
shell: bash
working-directory: ${{ env.GUI_DIR }}
run: |
export GOOS=darwin
export GOARCH="${{ matrix.arch }}"
# wails3 package builds with EXTRA_TAGS=npcgui (Package has no --tags
# flag; the var flows into the build dep) and then assembles a proper
# bin/npc-gui.app bundle with ad-hoc codesign.
wails3 package EXTRA_TAGS=npcgui
cd bin
# Guard the .app lookups so a no-match does not abort the script
# under `set -e -o pipefail`; keep the raw-binary fallback as safety.
app="$(ls -1d *.app 2>/dev/null | head -n 1 || true)"
if [ -z "$app" ]; then
app="$(find . -maxdepth 1 -type f -perm -111 -exec basename {} \; | head -n 1 || true)"
fi
if [ -z "$app" ]; then
echo "No build output found in bin"
ls -la
exit 1
fi
zip -q -r "$APP_NAME-${{ matrix.os_name }}-${{ matrix.arch }}.zip" "$app"
- name: Upload macOS artifact
uses: actions/upload-artifact@v4
with:
name: macos-builds-${{ matrix.arch }}
path: ${{ env.GUI_DIR }}/bin/${{ env.APP_NAME }}-${{ matrix.os_name }}-${{ matrix.arch }}.zip
- name: Upload macOS release asset
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
with:
files: ${{ env.GUI_DIR }}/bin/${{ env.APP_NAME }}-${{ matrix.os_name }}-${{ matrix.arch }}.zip
tag_name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ==================== Linux GUI ====================
build_linux_gui:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- platform: linux/amd64
os_name: linux
arch: amd64
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential libgtk-4-dev libwebkitgtk-6.0-dev libsoup-3.0-dev libjavascriptcoregtk-6.0-dev libayatana-appindicator3-dev librsvg2-dev patchelf pkg-config
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: yarn
cache-dependency-path: ${{ env.FRONTEND_DIR }}/yarn.lock
- name: Enable Yarn (corepack)
run: corepack enable
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ${{ env.GUI_DIR }}/go.mod
check-latest: true
- name: Install Wails CLI
run: go install github.com/wailsapp/wails/v3/cmd/wails3@${{ env.WAILS_VERSION }}
working-directory: ${{ env.GUI_DIR }}
- name: Build and package (Linux)
shell: bash
working-directory: ${{ env.GUI_DIR }}
run: |
export GOOS=linux
export GOARCH="${{ matrix.arch }}"
wails3 build --tags npcgui
cd bin
bin="$(find . -maxdepth 1 -type f -perm -111 -printf '%f\n' | head -n 1)"
if [ -z "$bin" ]; then
echo "No executable file found in bin"
ls -la
exit 1
fi
zip -q "$APP_NAME-${{ matrix.os_name }}-${{ matrix.arch }}.zip" "$bin"
- name: Upload Linux artifact
uses: actions/upload-artifact@v4
with:
name: linux-builds-${{ matrix.arch }}
path: ${{ env.GUI_DIR }}/bin/${{ env.APP_NAME }}-${{ matrix.os_name }}-${{ matrix.arch }}.zip
- name: Upload Linux release asset
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
with:
files: ${{ env.GUI_DIR }}/bin/${{ env.APP_NAME }}-${{ matrix.os_name }}-${{ matrix.arch }}.zip
tag_name: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+1 -1
View File
@@ -12,7 +12,7 @@
---
## 💰 赞助 / 推荐
#### 【腾讯云】[2核2G4M 服务器新客99元/年起](https://cloud.tencent.com/act/cps/redirect?redirect=6544&cps_key=de079542f18563fceb5c9b687dad2943&from=console)
#### 【腾讯云】— [WorkBuddy 全场景 AI 办公工作台](https://curl.qcloud.com/Fw85I52h)
#### 【NATNPS 云穿透】 — [无需自备服务器,注册即用,免费 3M 带宽 / 2 条隧道](https://natnps.com/register?utm_from=MQ==)
+16
View File
@@ -0,0 +1,16 @@
# 部署端使用的 compose(放到服务器的 DEPLOY_PATH 目录下)
# 管理后台:http://<服务器IP>:8081 默认账号密码见 conf/nps.conf(admin/123,务必修改)
# npc(客户端)镜像是 git.viaeon.com/admin/npc:latest,通常跑在别的机器上,不在此 compose 内
services:
nps:
image: git.viaeon.com/admin/nps:latest
container_name: nps
restart: unless-stopped
ports:
- "8081:8081" # web 管理面板
- "8024:8024" # 桥接端口,npc 连这个
- "80:80" # http 代理(按需)
- "443:443" # https 代理(按需)
volumes:
- ./conf:/conf
+5
View File
@@ -275,6 +275,11 @@ startPop:
if element != nil {
return
}
// the element counted in length may have been taken by release() when the
// window was closed concurrently, re-check the length instead of spinning forever
if length, _ = Self.chain.head.unpack(atomic.LoadUint64(&Self.lengthWait)); length == 0 {
goto startPop
}
runtime.Gosched() // another goroutine is still pushing
}
}
+33
View File
@@ -0,0 +1,33 @@
package nps_mux
import (
"io"
"sync/atomic"
"testing"
"time"
)
// A reader that has already seen an element counted in length must not spin
// forever when release() takes that element first because the conn was closed.
func TestReceiveWindowQueuePopAfterConcurrentRelease(t *testing.T) {
q := newReceiveWindowQueue()
// the reader sees one element in the queue...
atomic.StoreUint64(&q.lengthWait, q.chain.head.pack(1, 0))
done := make(chan error, 1)
go func() {
_, err := q.Pop()
done <- err
}()
time.Sleep(10 * time.Millisecond)
// ...but the window is closed and release() drains that element first
q.Stop()
atomic.StoreUint64(&q.lengthWait, 0)
select {
case err := <-done:
if err != io.EOF {
t.Fatalf("Pop returned %v, want io.EOF", err)
}
case <-time.After(time.Second):
t.Fatal("Pop is still spinning after the queue was stopped and drained")
}
}