Skip to content

Commit 268ee50

Browse files
committed
fixed: fixed push bug
0 parents  commit 268ee50

34 files changed

+1738
-0
lines changed

.github/workflows/release.yaml

+197
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
name: Go Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags (e.g., v1.2.3)
7+
# branches:
8+
# - main # Trigger on push to main branch as well
9+
workflow_dispatch:
10+
inputs:
11+
tag_name:
12+
description: 'Tag name for the release'
13+
required: true
14+
default: 'v1.2.3' # Default tag name
15+
16+
permissions:
17+
contents: write # Allow writing to GitHub releases
18+
19+
env:
20+
PROJECT_NAME: ${{ github.event.repository.name }}
21+
BUILD_DATE: ${{ github.run_id }}
22+
VERSION: ${{ github.ref_name }} # Dynamic version based on the tag name
23+
RELEASE_DIR: release
24+
RELEASE_NOTICES: |
25+
- [👏] 更新支持学习公社
26+
- [👏] 项目规范化迁移
27+
- [👏] 支持IP代理池文件接入(挂服务器减少封号风险,挂服务器的请务必使用ip代理池,因为服务器公网IP是固定的,很容易会被侦测到)
28+
- [‍🔧] 修复部分BUG,提高稳定性
29+
30+
注:等GO版本追平Java版本功能后Java版本将不再进行维护,后续将主要针对GO版本进行维护,Java将不会更新新功能和适配新平台。
31+
jobs:
32+
# Linux build job
33+
build-linux:
34+
name: Build Linux
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Checkout code
38+
uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0 # Fetch full git history for versioning
41+
42+
# Install necessary dependencies
43+
- name: Install dependencies
44+
run: |
45+
sudo apt-get update
46+
sudo apt-get install -y libasound2-dev pkg-config gcc-aarch64-linux-gnu
47+
48+
# Set up Go
49+
- name: Set up Go
50+
uses: actions/setup-go@v5
51+
with:
52+
go-version-file: 'go.mod' # Use Go version from go.mod
53+
cache: true # Enable dependency caching
54+
55+
- name: Get dependencies
56+
run: |
57+
export GOPROXY=direct
58+
export GONOSUMDB=*
59+
go mod tidy
60+
61+
- name: Prepare Release Directory #创建压缩目录
62+
run: mkdir -p ${{ env.RELEASE_DIR }}/yatori-go-console.${{env.VERSION}}-linux-amd64-release
63+
64+
# Build Linux AMD64
65+
- name: Build Linux AMD64
66+
run: |
67+
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
68+
-o ${{ env.RELEASE_DIR }}/yatori-go-console.${{env.VERSION}}-linux-amd64-release/${{ env.PROJECT_NAME }}
69+
- name: Create release tar
70+
run: | # 打包发布版本压缩包
71+
cp command/config.yaml ${{ env.RELEASE_DIR }}/yatori-go-console.${{env.VERSION}}-linux-amd64-release
72+
cd ${{ env.RELEASE_DIR }}
73+
tar -czvf yatori-go-console.${{env.VERSION}}-linux-amd64-release.tar.gz yatori-go-console.${{env.VERSION}}-linux-amd64-release
74+
rm -rf yatori-go-console.${{env.VERSION}}-linux-amd64-release
75+
cd ..
76+
# Create GitHub Release
77+
- name: Create GitHub Release with custom notes
78+
uses: softprops/action-gh-release@v2
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
with:
82+
files: ${{ env.RELEASE_DIR }}/* # 文件发布目录
83+
# generate_release_notes: true # 自动发行说明
84+
draft: false # 不创建草稿发布
85+
prerelease: false # 不标记为预发布
86+
tag_name: ${{ env.VERSION }} # 从标签中使用动态版本
87+
body: ${{env.RELEASE_NOTICES}} # 使用读取到的发布说明内容
88+
89+
# Windows build job
90+
build-windows:
91+
name: Build Windows
92+
runs-on: windows-latest
93+
needs: build-linux # Ensure Linux build completes first
94+
steps:
95+
- name: Checkout code
96+
uses: actions/checkout@v4
97+
with:
98+
fetch-depth: 0 # Fetch full git history for versioning
99+
100+
# Set up Go for Windows
101+
- name: Set up Go
102+
uses: actions/setup-go@v5
103+
with:
104+
go-version-file: 'go.mod' # Use Go version from go.mod
105+
cache: true # Enable dependency caching
106+
107+
- name: Get dependencies
108+
run: |
109+
set GOPROXY=direct
110+
set GONOSUMDB=*
111+
go clean -modcache
112+
del go.sum
113+
go get -u ./...
114+
go mod tidy
115+
116+
- name: Prepare Release Directory
117+
run: mkdir -p ${{ env.RELEASE_DIR }}\yatori-go-console.${{env.VERSION}}-windows-amd64-release
118+
119+
# Build Windows AMD64
120+
- name: Build Windows AMD64
121+
run: |
122+
set CGO_ENABLED=1
123+
set GOOS=windows
124+
set GOARCH=amd64
125+
go build -o ${{ env.RELEASE_DIR }}\yatori-go-console.${{env.VERSION}}-windows-amd64-release\${{ env.PROJECT_NAME }}.exe
126+
# tar -czvf yatori-go-console.${{env.VERSION}}-windows-amd64-release.tar.gz yatori-go-console.${{env.VERSION}}-windows-amd64-release 这个是windows打包tar.gz包的
127+
- name: Create Release zip
128+
run: |
129+
copy command\config.yaml ${{ env.RELEASE_DIR }}\yatori-go-console.${{env.VERSION}}-windows-amd64-release
130+
copy command\start.bat ${{ env.RELEASE_DIR }}\yatori-go-console.${{env.VERSION}}-windows-amd64-release
131+
cd ${{ env.RELEASE_DIR }}
132+
Compress-Archive -Path "yatori-go-console.${{env.VERSION}}-windows-amd64-release" -DestinationPath "yatori-go-console.${{env.VERSION}}-windows-amd64-release.zip"
133+
Remove-Item -Recurse -Force "yatori-go-console.${{env.VERSION}}-windows-amd64-release"
134+
cd ..
135+
# Create GitHub Release
136+
- name: Create Release
137+
uses: softprops/action-gh-release@v2
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140+
with:
141+
files: ${{ env.RELEASE_DIR }}/* # 文件发布目录
142+
generate_release_notes: true # 自动发行说明
143+
draft: false # 不创建草稿发布
144+
prerelease: false # 不标记为预发布
145+
tag_name: ${{ env.VERSION }} # 从标签中使用动态版本
146+
# # Create release on GitHub
147+
# release:
148+
# name: Create Release
149+
# runs-on: ubuntu-latest
150+
# needs: [build-linux, build-windows]
151+
# steps:
152+
# - name: Checkout code
153+
# uses: actions/checkout@v4
154+
# with:
155+
# fetch-depth: 0
156+
#
157+
# - name: Prepare Release Directory
158+
# run: mkdir -p ${{ env.RELEASE_DIR }}
159+
#
160+
# # List files to verify the release directory contains binaries
161+
# - name: List files in release directory
162+
# run: |
163+
# ls -l ${{ env.RELEASE_DIR }}
164+
#
165+
# # Create Source Code Tarball
166+
# - name: Create Source Code Tarball
167+
# run: |
168+
# tar -czvf ${{ env.RELEASE_DIR }}/${{ env.PROJECT_NAME }}_${{ env.BUILD_DATE }}_source.tar.gz \
169+
# --exclude=.git \
170+
# --exclude=${{ env.RELEASE_DIR }} \
171+
# .
172+
#
173+
# # Create Source Code Zip
174+
# - name: Create Source Code Zip
175+
# run: |
176+
# zip -r ${{ env.RELEASE_DIR }}/${{ env.PROJECT_NAME }}_${{ env.BUILD_DATE }}_source.zip \
177+
# . \
178+
# -x .git\* \
179+
# -x release\*
180+
#
181+
# # Generate SHA256 Checksums
182+
# - name: Generate SHA256 Checksums
183+
# run: |
184+
# cd ${{ env.RELEASE_DIR }}
185+
# sha256sum * > ${{ env.PROJECT_NAME }}_${{ env.BUILD_DATE }}_checksums.txt
186+
#
187+
# # Create GitHub Release
188+
# - name: Create Release
189+
# uses: softprops/action-gh-release@v2
190+
# env:
191+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
192+
# with:
193+
# files: ${{ env.RELEASE_DIR }}/* # 文件发布目录
194+
# generate_release_notes: true # 自动发行说明
195+
# draft: false # 不创建草稿发布
196+
# prerelease: false # 不标记为预发布
197+
# tag_name: ${{ env.VERSION }} # 从标签中使用动态版本

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# exclude exe
2+
*.exe
3+
assets/*
4+
./ip.txt
5+
./logo.txt
6+
./.idea/*

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 ChangBaiQi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.PHONY: all build run gotool clean help
2+
3+
BINARY_NAME="app"
4+
RELEASE_DIR="release"
5+
6+
7+
build-all: gotool
8+
mkdir -p $(RELEASE_DIR)
9+
make build-linux
10+
make build-windows
11+
12+
build-linux:
13+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(RELEASE_DIR)/$(BINARY_NAME)
14+
15+
build-windows:
16+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o $(RELEASE_DIR)/$(BINARY_NAME).exe
17+
18+
run:
19+
@go run ./
20+
21+
gotool:
22+
go fmt ./
23+
go vet ./
24+
25+
clean:
26+
@if [ -f $(RELEASE_DIR)/$(BINARY_NAME) ] ; then rm $(RELEASE_DIR)/** ; fi
27+
28+
help:
29+
@echo "make - 格式化 Go 代码, 并编译生成二进制文件"
30+
@echo "make build - 编译 Go 代码, 生成二进制文件"
31+
@echo "make run - 直接运行 Go 代码"
32+
@echo "make clean - 移除二进制文件和 vim swap files"
33+
@echo "make gotool - 运行 Go 工具 'fmt' and 'vet'"

0 commit comments

Comments
 (0)