├── compare.sh
├── .github
└── workflows
│ ├── sync.yml
│ ├── build_v0.yml
│ └── build.yml
└── README.md
/compare.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [[ "$LOCALVERSION" == "$REMOTEVERSION" ]]; then
4 | echo "SYNCED=1" >> $GITHUB_ENV
5 | else
6 | echo "SYNCED=0" >> $GITHUB_ENV
7 | fi
8 |
--------------------------------------------------------------------------------
/.github/workflows/sync.yml:
--------------------------------------------------------------------------------
1 | name: Run Tests
2 |
3 | on:
4 | schedule:
5 | - cron: '0 16 */1 * *'
6 | workflow_dispatch:
7 |
8 | jobs:
9 | tests:
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v4
13 | - name: compare versions
14 | run: |
15 | export REMOTEVERSION=$(wget -qO- https://api.github.com/repos/naiba/nezha/tags | gawk -F '["v]' '/name/{print "v"$5;exit}')
16 | export LOCALVERSION=$(curl --location --silent --fail --show-error "https://api.github.com/repos/amclubs/am-nezha-freebsd/releases/latest" | grep -oP '"tag_name":\s*"\K[^"]+')
17 | bash compare.sh
18 |
19 | - name: Trigger release
20 | if: ${{ env.SYNCED == 0 }}
21 | uses: actions/github-script@v6
22 | with:
23 | github-token: ${{ secrets.PAT_TOKEN }}
24 | script: |
25 | await github.rest.actions.createWorkflowDispatch({
26 | owner: 'amclubs',
27 | repo: 'am-nezha-freebsd',
28 | workflow_id: 'build.yml',
29 | ref: 'main'
30 | })
31 |
32 | # - name: Delete workflow runs
33 | # if: ${{ env.SYNCED == 1 }}
34 | # uses: Mattraks/delete-workflow-runs@v2
35 | # with:
36 | # token: ${{ github.token }}
37 | # repository: ${{ github.repository }}
38 | # retain_days: 1
39 | # keep_minimum_runs: 8
40 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [am-nezha-freebsd](https://github.com/amclubs/am-nezha-freebsd/)
2 | Automatically build nezha (FreeBSD version)
3 |
4 | #
5 | ▶️ **新人[YouTube](https://youtube.com/@am_clubs?sub_confirmation=1)** 需要您的支持,请务必帮我**点赞**、**关注**、**打开小铃铛**,***十分感谢!!!*** ✅
6 | 🎁请 **follow** 我的[GitHub](https://github.com/amclubs)、给我所有项目一个 **Star** 星星(拜托了)!你的支持是我不断前进的动力! 💖
7 | ✅**解锁更多技能** [加入TG群【am_clubs】](https://t.me/am_clubs)、[YouTube频道【@am_clubs】](https://youtube.com/@am_clubs?sub_confirmation=1)、[【博客(国内)】](https://amclubss.com)、[【博客(国际)】](https://amclubs.blogspot.com)
8 | ✅点击观看教程[CLoudflare免费节点](https://www.youtube.com/playlist?list=PLGVQi7TjHKXbrY0Pk8gm3T7m8MZ-InquF) | [VPS搭建节点](https://www.youtube.com/playlist?list=PLGVQi7TjHKXaVlrHP9Du61CaEThYCQaiY) | [获取免费域名](https://www.youtube.com/playlist?list=PLGVQi7TjHKXZGODTvB8DEervrmHANQ1AR) | [免费VPN](https://www.youtube.com/playlist?list=PLGVQi7TjHKXY7V2JF-ShRSVwGANlZULdk) | [IPTV源](https://www.youtube.com/playlist?list=PLGVQi7TjHKXbkozDYVsDRJhbnNaEOC76w) | [Mac和Win工具](https://www.youtube.com/playlist?list=PLGVQi7TjHKXYBWu65yP8E08HxAu9LbCWm) | [AI分享](https://www.youtube.com/playlist?list=PLGVQi7TjHKXaodkM-mS-2Nwggwc5wRjqY)
9 |
10 | #
11 |
12 | [点击展开] 赞赏支持 ~🧧
13 | *我非常感谢您的赞赏和支持,它们将极大地激励我继续创新,持续产生有价值的工作。*
14 |
15 | - **USDT-TRC20:** `TWTxUyay6QJN3K4fs4kvJTT8Zfa2mWTwDD`
16 | - **TRX-TRC20:** `TWTxUyay6QJN3K4fs4kvJTT8Zfa2mWTwDD`
17 |
18 |
19 |

20 | TRC10/TRC20扫码支付
21 |
22 |
23 |
24 |
25 | #
26 | 免责声明:
27 | - 1、该项目设计和开发仅供学习、研究和安全测试目的。请于下载后 24 小时内删除, 不得用作任何商业用途, 文字、数据及图片均有所属版权, 如转载须注明来源。
28 | - 2、使用本程序必循遵守部署服务器所在地区的法律、所在国家和用户所在国家的法律法规。对任何人或团体使用该项目时产生的任何后果由使用者承担。
29 | - 3、作者不对使用该项目可能引起的任何直接或间接损害负责。作者保留随时更新免责声明的权利,且不另行通知。
30 |
31 |
--------------------------------------------------------------------------------
/.github/workflows/build_v0.yml:
--------------------------------------------------------------------------------
1 | name: Build Nezha
2 |
3 | on: workflow_dispatch
4 |
5 | jobs:
6 | test:
7 | runs-on: ubuntu-latest
8 | name: Build Nezha
9 | steps:
10 | - uses: actions/checkout@v4
11 | - name: Build Nezha
12 | uses: vmactions/freebsd-vm@v1
13 | with:
14 | usesh: true
15 | release: 13.2
16 | prepare: |
17 | pkg install -y node wget curl git go121 gcc bash gawk gsed
18 | ln -s /usr/local/bin/go121 /usr/local/bin/go
19 | run: |
20 | export LATEST_APP=$(wget -qO- https://api.github.com/repos/naiba/nezha/tags | gawk -F '["v]' '/name/{print "v"$5;exit}')
21 | git clone -b $LATEST_APP https://github.com/naiba/nezha
22 | rm nezha/pkg/geoip/geoip.db
23 | wget -O nezha/pkg/geoip/geoip.db https://ipinfo.io/data/free/country.mmdb?token=${{secrets.IPINFO_TOKEN}}
24 | cd nezha/cmd/dashboard
25 | bash ../../../build.sh
26 |
27 | - name: Upload artifact
28 | uses: actions/upload-artifact@main
29 | with:
30 | name: nezha-freebsd
31 | path: |
32 | nezha/cmd/dashboard/dashboard
33 |
34 | - name: Generate release tag
35 | id: tag
36 | run: echo "release_tag=$(wget -qO- https://api.github.com/repos/naiba/nezha/tags | gawk -F '["v]' '/name/{print "v"$5;exit}')" >> $GITHUB_OUTPUT
37 |
38 | - name: Create release
39 | uses: softprops/action-gh-release@v1
40 | env:
41 | GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
42 | with:
43 | tag_name: ${{ steps.tag.outputs.release_tag }}
44 | files: |
45 | nezha/cmd/dashboard/dashboard
46 |
47 | - name: Delete workflow runs
48 | uses: Mattraks/delete-workflow-runs@v2
49 | with:
50 | token: ${{ github.token }}
51 | repository: ${{ github.repository }}
52 | retain_days: 1
53 | keep_minimum_runs: 8
54 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build and Release
2 | on:
3 | push:
4 | tags:
5 | - 'v*'
6 | workflow_dispatch:
7 | inputs:
8 | tag:
9 | description: 'Tag to release'
10 | required: false
11 |
12 | jobs:
13 | release:
14 | name: build and release
15 | runs-on: ubuntu-latest
16 | steps:
17 | - uses: actions/checkout@v4
18 |
19 | - name: Setup and Build on FreeBSD
20 | uses: vmactions/freebsd-vm@v1
21 | with:
22 | usesh: true
23 | release: 14.1
24 | prepare: |
25 | pkg install -y wget curl git go121 gcc bash jq node zip
26 | ln -s /usr/local/bin/go121 /usr/local/bin/go
27 | run: |
28 | # Determine version
29 | if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.tag }}" ]; then
30 | VERSION=${{ github.event.inputs.tag }}
31 | else
32 | VERSION=$(curl -sL "https://api.github.com/repos/naiba/nezha/releases/latest" | jq -r .tag_name)
33 | fi
34 |
35 | if [ -z "${VERSION}" ]; then
36 | echo "Error: VERSION could not be determined" >&2
37 | exit 1
38 | fi
39 |
40 | echo "VERSION=${VERSION}" >> $GITHUB_ENV
41 | echo "Version set to: ${VERSION}"
42 |
43 | # Build the project
44 | version_num=${VERSION#v}
45 |
46 | if git ls-remote --tags https://github.com/naiba/nezha | grep -q "refs/tags/${VERSION}"; then
47 | git clone -b ${VERSION} https://github.com/naiba/nezha
48 | else
49 | echo "Error: Tag ${VERSION} not found in naiba/nezha repository" && exit 1
50 | fi
51 |
52 | # Clean old dist directories
53 | rm -rf nezha/cmd/dashboard/*-dist
54 |
55 | # Download and prepare admin-frontend
56 | wget -q https://github.com/nezhahq/admin-frontend/releases/latest/download/dist.zip -O admin-dist.zip
57 | unzip -q admin-dist.zip
58 | mv dist nezha/cmd/dashboard/admin-dist
59 | rm admin-dist.zip
60 |
61 | # Download and prepare user-frontend
62 | wget -q https://github.com/nezhahq/user-frontend/releases/latest/download/dist.zip -O user-dist.zip
63 | unzip -q user-dist.zip
64 | mv dist nezha/cmd/dashboard/user-dist
65 | rm user-dist.zip
66 |
67 | # Download and prepare nazhua-frontend
68 | wget -q https://github.com/hi2shark/nazhua/releases/latest/download/dist.zip -O nazhua-dist.zip
69 | unzip -q nazhua-dist.zip
70 | mv dist nezha/cmd/dashboard/nazhua-dist
71 | rm nazhua-dist.zip
72 |
73 | # Download GeoIP database
74 | rm -rf nezha/pkg/geoip/geoip.db
75 | wget -qO nezha/pkg/geoip/geoip.db https://ipinfo.io/data/free/country.mmdb?token=${{ secrets.IPINFO_TOKEN }}
76 |
77 | echo "====================0 Install Swag for Swagger docs ========================"
78 | # Install Swag for Swagger docs
79 | go install github.com/swaggo/swag/cmd/swag@latest
80 |
81 | # Ensure Swag is in PATH
82 | export PATH=$PATH:$(go env GOPATH)/bin
83 |
84 |
85 | echo "====================0 Install Swag init ========================"
86 | # Generate Swagger docs
87 | cd nezha
88 | $(go env GOPATH)/bin/swag init --pd -d . -g ./cmd/dashboard/main.go -o ./cmd/dashboard/docs --parseGoList=false
89 |
90 | # Build the project
91 | cd cmd/dashboard
92 | echo "====================0 go build ========================"
93 | go mod tidy
94 | go build -ldflags="-s -w --extldflags '-static -fpic' -X github.com/naiba/nezha/service/singleton.Version=${version_num}"
95 | echo "====================1 file dashboard ========================"
96 | file dashboard
97 |
98 | # Create output directory
99 | mkdir -p ../../output
100 | mv dashboard ../../output/nezha-dashboard
101 |
102 | # Prepare config.yaml
103 | mkdir -p ../../output/data
104 | # cp -rf ../../script/config.yaml ../../output/data/config.yaml
105 |
106 | # Compress dist files
107 | cd ../../output
108 |
109 | zip -qr nezha-dashboard.zip .
110 | mv nezha-dashboard.zip ..
111 |
112 | tar -czf nezha-dashboard.tar.gz *
113 |
114 | mv ../nezha-dashboard.zip .
115 | echo "====================3========================"
116 | ls -all
117 |
118 | echo "====================4========================"
119 | file nezha-dashboard
120 |
121 | - name: Upload artifact
122 | uses: actions/upload-artifact@v4
123 | with:
124 | name: nezha-freebsd
125 | path: |
126 | nezha/output/*
127 |
128 | - name: Release
129 | uses: ncipollo/release-action@v1
130 | with:
131 | tag: ${{ env.VERSION }}
132 | artifacts: "nezha/output/*.zip,nezha/output/*.tar.gz"
133 | generateReleaseNotes: true
134 | makeLatest: legacy
135 | omitBody: false
136 | omitBodyDuringUpdate: false
137 | omitDraftDuringUpdate: false
138 | omitName: false
139 | omitNameDuringUpdate: false
140 | omitPrereleaseDuringUpdate: false
141 | removeArtifacts: false
142 | replacesArtifacts: true
143 | skipIfReleaseExists: false
144 | updateOnlyUnreleased: false
145 | env:
146 | GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
147 |
--------------------------------------------------------------------------------