mirror of https://github.com/bjdgyc/anylink.git
修改readme
This commit is contained in:
parent
13de601474
commit
911b96cc74
|
@ -12,14 +12,14 @@
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_dispatch:
|
||||||
branches: [ "main", "dev" ]
|
|
||||||
pull_request:
|
|
||||||
# The branches below must be a subset of the branches above
|
|
||||||
branches: [ "main", "dev" ]
|
|
||||||
|
|
||||||
schedule:
|
# push:
|
||||||
- cron: '32 12 * * 5'
|
# branches: [ "main", "dev" ]
|
||||||
|
# pull_request:
|
||||||
|
# branches: [ "main", "dev" ]
|
||||||
|
# schedule:
|
||||||
|
# - cron: '32 12 * * 5'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
analyze:
|
analyze:
|
||||||
|
@ -39,34 +39,34 @@ jobs:
|
||||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v2
|
uses: github/codeql-action/init@v2
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
# By default, queries listed here will override any specified in a config file.
|
# By default, queries listed here will override any specified in a config file.
|
||||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v2
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
# and modify them (or add more) to build your code if your project
|
# and modify them (or add more) to build your code if your project
|
||||||
# uses a compiled language
|
# uses a compiled language
|
||||||
|
|
||||||
#- run: |
|
#- run: |
|
||||||
# make bootstrap
|
# make bootstrap
|
||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v2
|
uses: github/codeql-action/analyze@v2
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
name: go-update
|
name: go-update
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
schedule:
|
# schedule:
|
||||||
- cron: "1 2 * * 5"
|
# - cron: "1 2 * * 5"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
go:
|
go:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -26,7 +27,7 @@ jobs:
|
||||||
go get -u
|
go get -u
|
||||||
go mod download
|
go mod download
|
||||||
|
|
||||||
- name: Git push
|
- name: Git push
|
||||||
run: |
|
run: |
|
||||||
git init
|
git init
|
||||||
git config --local user.name "github-actions[bot]"
|
git config --local user.name "github-actions[bot]"
|
||||||
|
@ -38,7 +39,7 @@ jobs:
|
||||||
git commit -m "update go.mod $(date +%Y.%m.%d.%H.%M)"
|
git commit -m "update go.mod $(date +%Y.%m.%d.%H.%M)"
|
||||||
#git push -f -u origin _autoaction
|
#git push -f -u origin _autoaction
|
||||||
git push -u origin _autoaction
|
git push -u origin _autoaction
|
||||||
|
|
||||||
# 删除无用 workflow runs;
|
# 删除无用 workflow runs;
|
||||||
- name: Delete workflow runs
|
- name: Delete workflow runs
|
||||||
uses: GitRML/delete-workflow-runs@main
|
uses: GitRML/delete-workflow-runs@main
|
|
@ -1,10 +1,12 @@
|
||||||
name: Go
|
name: Go
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
workflow_dispatch:
|
||||||
branches: [ "main", "dev" ]
|
|
||||||
pull_request:
|
# push:
|
||||||
branches: [ "main", "dev" ]
|
# branches: [ "main", "dev" ]
|
||||||
|
# pull_request:
|
||||||
|
# branches: [ "main", "dev" ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
name: release-tag-version
|
name: release-tag-version
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v0.*"
|
- "v0.*"
|
||||||
|
@ -9,20 +10,38 @@ jobs:
|
||||||
Build:
|
Build:
|
||||||
name: build-binary
|
name: build-binary
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
TZ: Asia/Shanghai
|
||||||
steps:
|
steps:
|
||||||
|
- name: Hello world
|
||||||
|
run: |
|
||||||
|
uname -a
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- run: git fetch --unshallow --quiet --tags --force
|
|
||||||
|
|
||||||
- uses: actions/setup-go@v4
|
- uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.20'
|
||||||
go-version-file: 'server/go.mod'
|
|
||||||
cache-dependency-path: 'server/go.sum'
|
cache-dependency-path: 'server/go.sum'
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '16'
|
node-version: '16'
|
||||||
|
cache: 'yarn'
|
||||||
|
cache-dependency-path: 'web/yarn.lock'
|
||||||
|
|
||||||
Docker:
|
- # https://github.com/docker/setup-qemu-action
|
||||||
name: build-docker
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
mkdir server/ui
|
||||||
|
touch server/ui/index.html
|
||||||
|
sudo apt-get install -y -q gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
|
||||||
|
aarch64-linux-gnu-gcc -v
|
||||||
|
aarch64-linux-gnu-g++ -v
|
||||||
|
bash build.sh github_action
|
||||||
|
|
||||||
|
# Docker:
|
||||||
|
# name: build-docker
|
|
@ -3,5 +3,4 @@
|
||||||
anylink-deploy
|
anylink-deploy
|
||||||
anylink-deploy.tar.gz
|
anylink-deploy.tar.gz
|
||||||
|
|
||||||
dist
|
dist
|
||||||
godist
|
|
|
@ -1,32 +1,61 @@
|
||||||
#https://goreleaser.com/static/schema.json
|
#https://goreleaser.com/static/schema.json
|
||||||
|
|
||||||
|
# release --skip=publish
|
||||||
|
|
||||||
# goreleaser build --skip=validate --clean --debug
|
# goreleaser build --skip=validate --clean --debug
|
||||||
|
|
||||||
|
# GOPROXY=https://goproxy.cn
|
||||||
|
|
||||||
|
# docker run -it --rm -v $PWD:/app -v /go:/go -w /app --platform=linux/arm64
|
||||||
|
|
||||||
|
# docker run -it --rm -v $PWD:/app -v /go:/go -w /app goreleaser/goreleaser-cross build --skip=validate --clean --debug
|
||||||
|
|
||||||
|
# docker run -it --rm -v $PWD:/app -v /go:/go -w /app bjdgyc/dcross goreleaser build --skip=validate --clean --debug
|
||||||
|
|
||||||
version: 1
|
version: 1
|
||||||
|
|
||||||
dist: godist
|
dist: dist
|
||||||
|
|
||||||
before:
|
before:
|
||||||
hooks:
|
hooks:
|
||||||
# You may remove this if you don't use go modules.
|
- pwd
|
||||||
#- go mod tidy
|
# - cmd: go mod tidy
|
||||||
# you may remove this if you don't need go generate
|
# dir:
|
||||||
#- go generate ./...
|
# "{{ dir .Dist}}"
|
||||||
|
# output: true
|
||||||
|
# - cmd: go generate
|
||||||
|
# dir:
|
||||||
|
# "{{ dir .Dist}}"
|
||||||
|
# output: true
|
||||||
|
|
||||||
builds:
|
builds:
|
||||||
- id: "build"
|
- id: "build"
|
||||||
#main: .
|
#main: .
|
||||||
dir: ./server
|
dir: ./server
|
||||||
|
hooks:
|
||||||
|
pre:
|
||||||
|
- cmd: go mod tidy
|
||||||
|
dir: ./server
|
||||||
|
output: true
|
||||||
|
- cmd: go generate
|
||||||
|
dir: ./server
|
||||||
|
output: true
|
||||||
|
# {{- if eq .Arch "amd64" }}CC=x86_64-linux-gnu-gcc CXX=x86_64-linux-gnu-g++{{- end }}
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=1
|
- CGO_ENABLED=1
|
||||||
- >-
|
- >-
|
||||||
|
{{- if eq .Os "linux" }}
|
||||||
|
{{- if eq .Arch "amd64" }}CC=x86_64-linux-musl-gcc{{- end }}
|
||||||
|
|
||||||
|
{{- if eq .Arch "arm64" }}CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++{{- end }}
|
||||||
|
{{- end }}
|
||||||
{{- if eq .Os "darwin" }}
|
{{- if eq .Os "darwin" }}
|
||||||
{{- if eq .Arch "amd64"}}CC=o64-clang{{- end }}
|
{{- if eq .Arch "amd64"}}CC=o64-clang{{- end }}
|
||||||
{{- if eq .Arch "arm64"}}CC=aarch64-apple-darwin20.2-clang{{- end }}
|
{{- if eq .Arch "arm64"}}CC=oa64-clang{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if eq .Os "linux" }}
|
{{- if eq .Os "windows" }}
|
||||||
{{- if eq .Arch "arm64" }}CC=aarch64-linux-gnu-gcc{{- end }}
|
{{- if eq .Arch "amd64"}}CC=x86_64-w64-mingw32-gcc{{- end }}
|
||||||
{{- if eq .Arch "arm" }}CC=arm-linux-gnueabi-gcc{{- end }}
|
{{- if eq .Arch "arm64"}}CC=aarch64-linux-gnu-gcc{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
|
@ -34,9 +63,22 @@ builds:
|
||||||
#- windows
|
#- windows
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- amd64
|
||||||
- arm64
|
#- arm64
|
||||||
- arm
|
# https://go.dev/wiki/MinimumRequirements
|
||||||
|
goamd64:
|
||||||
|
- v1
|
||||||
|
command: build
|
||||||
|
flags:
|
||||||
|
- -trimpath
|
||||||
|
- -tags osusergo,netgo,sqlite_omit_load_extension
|
||||||
|
ldflags:
|
||||||
|
# go tool link -help
|
||||||
|
# go tool compile -help
|
||||||
|
# -linkmode external
|
||||||
|
# -extld=$CC
|
||||||
|
# -fpic 作为动态链接库的时候 需要添加
|
||||||
|
|
||||||
|
- -s -w -extldflags '-static' -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=dcross
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
- id: "archive1"
|
- id: "archive1"
|
||||||
|
|
43
build.sh
43
build.sh
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
github_action=$1
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
function RETVAL() {
|
function RETVAL() {
|
||||||
rt=$1
|
rt=$1
|
||||||
|
@ -12,32 +14,53 @@ function RETVAL() {
|
||||||
#当前目录
|
#当前目录
|
||||||
cpath=$(pwd)
|
cpath=$(pwd)
|
||||||
|
|
||||||
ver=`cat server/base/app_ver.go | grep APP_VER | awk '{print $3}' | sed 's/"//g'`
|
#ver=`cat server/base/app_ver.go | grep APP_VER | awk '{print $3}' | sed 's/"//g'`
|
||||||
|
ver=$(cat version)
|
||||||
echo "当前版本 $ver"
|
echo "当前版本 $ver"
|
||||||
|
|
||||||
echo "编译前端项目"
|
echo "编译前端项目"
|
||||||
cd $cpath/web
|
cd $cpath/web
|
||||||
#国内可替换源加快速度
|
#国内可替换源加快速度
|
||||||
#npx browserslist@latest --update-db
|
#npx browserslist@latest --update-db
|
||||||
#npm install --registry=https://registry.npm.taobao.org
|
if [ "$github_action" == "github_action" ]; then
|
||||||
#npm install
|
yarn install --registry=https://registry.npmmirror.com
|
||||||
#npm run build
|
else
|
||||||
|
yarn install
|
||||||
|
fi
|
||||||
|
|
||||||
yarn install --registry=https://registry.npmmirror.com
|
|
||||||
yarn run build
|
yarn run build
|
||||||
|
|
||||||
|
|
||||||
RETVAL $?
|
RETVAL $?
|
||||||
|
|
||||||
echo "编译二进制文件"
|
echo "编译二进制文件"
|
||||||
cd $cpath/server
|
cd $cpath/server
|
||||||
rm -rf ui
|
rm -rf ui
|
||||||
cp -rf $cpath/web/ui .
|
cp -rf $cpath/web/ui .
|
||||||
#国内可替换源加快速度
|
|
||||||
export GOPROXY=https://goproxy.io
|
flags="-v -trimpath -extldflags '-static' -tags osusergo,netgo,sqlite_omit_load_extension"
|
||||||
|
ldflags="-s -w -X main.appVer=$ver -X main.commitId=$(git rev-parse HEAD) -X main.date=$(date --iso-8601=seconds)"
|
||||||
|
|
||||||
|
if [ "$github_action" == "github_action" ]; then
|
||||||
|
echo "github_action"
|
||||||
|
else
|
||||||
|
#国内可替换源加快速度
|
||||||
|
export GOPROXY=https://goproxy.io
|
||||||
|
go mod tidy
|
||||||
|
go build -o anylink "$flags" -ldflags "$ldflags"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
#github action
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go build -v -o anylink -trimpath -ldflags "-s -w -X main.CommitId=$(git rev-parse HEAD)"
|
go build -o anylink_amd64 "$flags" -ldflags "$ldflags"
|
||||||
RETVAL $?
|
|
||||||
|
#arm64交叉编译
|
||||||
|
CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ go build -o anylink_arm64 "$flags" -ldflags "$ldflags"
|
||||||
|
|
||||||
|
./anylink_amd64 -v
|
||||||
|
./anylink_arm64 -v
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
cd $cpath
|
cd $cpath
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ver=`cat server/base/app_ver.go | grep APP_VER | awk '{print $3}' | sed 's/"//g'`
|
ver=`cat server/base/app_ver.go | grep "APP_VER" | awk '{print $3}' | sed 's/"//g'`
|
||||||
echo $ver
|
echo $ver
|
||||||
|
|
||||||
#docker login -u bjdgyc
|
#docker login -u bjdgyc
|
||||||
|
|
|
@ -2,6 +2,12 @@ package base
|
||||||
|
|
||||||
const (
|
const (
|
||||||
APP_NAME = "AnyLink"
|
APP_NAME = "AnyLink"
|
||||||
// APP_VER app版本号
|
)
|
||||||
APP_VER = "0.10.2"
|
|
||||||
|
var (
|
||||||
|
// APP_VER app版本号
|
||||||
|
APP_VER = "0.0.1"
|
||||||
|
// 提交id
|
||||||
|
CommitId string
|
||||||
|
Date string
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package base
|
package base
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -17,8 +16,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// 提交id
|
|
||||||
CommitId string
|
|
||||||
// pass明文
|
// pass明文
|
||||||
passwd string
|
passwd string
|
||||||
// 生成otp
|
// 生成otp
|
||||||
|
@ -60,6 +57,15 @@ func execute() {
|
||||||
envs[rr.Key().String()] = rr.Value().Index(0).String()
|
envs[rr.Key().String()] = rr.Value().Index(0).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//移动配置解析代码
|
||||||
|
conf := linkViper.GetString("conf")
|
||||||
|
linkViper.SetConfigFile(conf)
|
||||||
|
err = linkViper.ReadInConfig()
|
||||||
|
if err != nil {
|
||||||
|
// 没有配置文件,直接报错
|
||||||
|
panic("config file err:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
if !runSrv {
|
if !runSrv {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
@ -106,19 +112,28 @@ func initCmd() {
|
||||||
|
|
||||||
cobra.OnInitialize(func() {
|
cobra.OnInitialize(func() {
|
||||||
linkViper.AutomaticEnv()
|
linkViper.AutomaticEnv()
|
||||||
conf := linkViper.GetString("conf")
|
|
||||||
|
|
||||||
_, err := os.Stat(conf)
|
//ver := linkViper.GetBool("version")
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
//if ver {
|
||||||
// 没有配置文件,不做处理
|
// printVersion()
|
||||||
panic(err)
|
// os.Exit(0)
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
linkViper.SetConfigFile(conf)
|
//return
|
||||||
err = linkViper.ReadInConfig()
|
//
|
||||||
if err != nil {
|
//conf := linkViper.GetString("conf")
|
||||||
panic("config file err:" + err.Error())
|
//_, err := os.Stat(conf)
|
||||||
}
|
//if errors.Is(err, os.ErrNotExist) {
|
||||||
|
// // 没有配置文件,不做处理
|
||||||
|
// panic("conf stat err:" + err.Error())
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//linkViper.SetConfigFile(conf)
|
||||||
|
//err = linkViper.ReadInConfig()
|
||||||
|
//if err != nil {
|
||||||
|
// panic("config file err:" + err.Error())
|
||||||
|
//}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,6 +179,6 @@ func initToolCmd() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func printVersion() {
|
func printVersion() {
|
||||||
fmt.Printf("%s v%s build on %s [%s, %s] commit_id(%s) \n",
|
fmt.Printf("%s v%s build on %s [%s, %s] %s commit_id(%s)\n",
|
||||||
APP_NAME, APP_VER, runtime.Version(), runtime.GOOS, runtime.GOARCH, CommitId)
|
APP_NAME, APP_VER, runtime.Version(), runtime.GOOS, runtime.GOARCH, Date, CommitId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,17 @@ import (
|
||||||
var uiData embed.FS
|
var uiData embed.FS
|
||||||
|
|
||||||
// 程序版本
|
// 程序版本
|
||||||
var CommitId string
|
var (
|
||||||
|
appVer string
|
||||||
|
commitId string
|
||||||
|
date string
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
base.CommitId = CommitId
|
|
||||||
admin.UiData = uiData
|
admin.UiData = uiData
|
||||||
|
base.APP_VER = appVer
|
||||||
|
base.CommitId = commitId
|
||||||
|
base.Date = date
|
||||||
|
|
||||||
base.Start()
|
base.Start()
|
||||||
handler.Start()
|
handler.Start()
|
||||||
|
|
Loading…
Reference in New Issue