Skip to content

Commit

Permalink
修改readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bjdgy committed Jan 28, 2024
1 parent 13de601 commit 911b96c
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 90 deletions.
64 changes: 32 additions & 32 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
name: "CodeQL"

on:
push:
branches: [ "main", "dev" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main", "dev" ]
workflow_dispatch:

schedule:
- cron: '32 12 * * 5'
# push:
# branches: [ "main", "dev" ]
# pull_request:
# branches: [ "main", "dev" ]
# schedule:
# - cron: '32 12 * * 5'

jobs:
analyze:
Expand All @@ -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

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# 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.
# 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
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# 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.
# 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

# 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)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# 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)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ 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
# uses a compiled language
# ✏️ 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
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: go-update
on:
workflow_dispatch:
schedule:
- cron: "1 2 * * 5"
# schedule:
# - cron: "1 2 * * 5"

jobs:
go:
runs-on: ubuntu-latest
Expand All @@ -26,7 +27,7 @@ jobs:
go get -u
go mod download
- name: Git push
- name: Git push
run: |
git init
git config --local user.name "github-actions[bot]"
Expand All @@ -38,7 +39,7 @@ jobs:
git commit -m "update go.mod $(date +%Y.%m.%d.%H.%M)"
#git push -f -u origin _autoaction
git push -u origin _autoaction
# 删除无用 workflow runs;
- name: Delete workflow runs
uses: GitRML/delete-workflow-runs@main
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Go

on:
push:
branches: [ "main", "dev" ]
pull_request:
branches: [ "main", "dev" ]
workflow_dispatch:

# push:
# branches: [ "main", "dev" ]
# pull_request:
# branches: [ "main", "dev" ]

jobs:

Expand Down
31 changes: 25 additions & 6 deletions .github/workflows/release-tag-version.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: release-tag-version

on:
workflow_dispatch:
push:
tags:
- "v0.*"
Expand All @@ -9,20 +10,38 @@ jobs:
Build:
name: build-binary
runs-on: ubuntu-latest
env:
TZ: Asia/Shanghai
steps:
- name: Hello world
run: |
uname -a
- uses: actions/checkout@v4

- run: git fetch --unshallow --quiet --tags --force

- uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version-file: 'server/go.mod'
cache-dependency-path: 'server/go.sum'

- uses: actions/setup-node@v4
with:
node-version: '16'
cache: 'yarn'
cache-dependency-path: 'web/yarn.lock'

- # https://github.com/docker/setup-qemu-action
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
# Docker:
# name: build-docker
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
anylink-deploy
anylink-deploy.tar.gz

dist
godist
dist
64 changes: 53 additions & 11 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,84 @@
#https://goreleaser.com/static/schema.json

# release --skip=publish

# 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

dist: godist
dist: dist

before:
hooks:
# You may remove this if you don't use go modules.
#- go mod tidy
# you may remove this if you don't need go generate
#- go generate ./...
- pwd
# - cmd: go mod tidy
# dir:
# "{{ dir .Dist}}"
# output: true
# - cmd: go generate
# dir:
# "{{ dir .Dist}}"
# output: true

builds:
- id: "build"
#main: .
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:
- 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 .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 }}
{{- if eq .Os "linux" }}
{{- if eq .Arch "arm64" }}CC=aarch64-linux-gnu-gcc{{- end }}
{{- if eq .Arch "arm" }}CC=arm-linux-gnueabi-gcc{{- end }}
{{- if eq .Os "windows" }}
{{- if eq .Arch "amd64"}}CC=x86_64-w64-mingw32-gcc{{- end }}
{{- if eq .Arch "arm64"}}CC=aarch64-linux-gnu-gcc{{- end }}
{{- end }}
goos:
- linux
#- darwin
#- windows
goarch:
- amd64
- arm64
- arm
#- arm64
# 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:
- id: "archive1"
Expand Down
43 changes: 33 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

github_action=$1

set -x
function RETVAL() {
rt=$1
Expand All @@ -12,32 +14,53 @@ function RETVAL() {
#当前目录
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 "编译前端项目"
cd $cpath/web
#国内可替换源加快速度
#npx browserslist@latest --update-db
#npm install --registry=https://registry.npm.taobao.org
#npm install
#npm run build
if [ "$github_action" == "github_action" ]; then
yarn install --registry=https://registry.npmmirror.com
else
yarn install
fi

yarn install --registry=https://registry.npmmirror.com
yarn run build


RETVAL $?

echo "编译二进制文件"
cd $cpath/server
rm -rf 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 build -v -o anylink -trimpath -ldflags "-s -w -X main.CommitId=$(git rev-parse HEAD)"
RETVAL $?
go build -o anylink_amd64 "$flags" -ldflags "$ldflags"

#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

Expand Down
2 changes: 1 addition & 1 deletion build_docker.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/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

#docker login -u bjdgyc
Expand Down
8 changes: 7 additions & 1 deletion server/base/app_ver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ package base

const (
APP_NAME = "AnyLink"
)

var (
// APP_VER app版本号
APP_VER = "0.10.2"
APP_VER = "0.0.1"
// 提交id
CommitId string
Date string
)
Loading

0 comments on commit 911b96c

Please sign in to comment.