├── .github └── workflows │ ├── build.yml │ └── sync.yml ├── README.md ├── build.sh └── compare.sh /.github/workflows/build.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/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/wansyu/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: 'wansyu', 27 | repo: '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 | # nezha-freebsd 2 | Automatically build nezha (FreeBSD version) 3 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | appName="nezha" 4 | builtAt="$(date +'%F %T %z')" 5 | version=$(git describe --long --tags --dirty --always) 6 | 7 | ldflags="\ 8 | -w -s \ 9 | --extldflags '-static -fpic' \ 10 | -X 'github.com/naiba/nezha/service/singleton.Version=$version' \ 11 | " 12 | 13 | go build -ldflags="$ldflags" -tags=jsoniter . 14 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------