Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update github action for build and release #26

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 33 additions & 74 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,81 +1,40 @@
name: Build and Release
name: release

on:
push:
branches:
- master
release:
types: [created] # 表示在创建新的 Release 时触发
# push:
workflow_dispatch:

permissions:
contents: write
packages: write

jobs:
build:
build-go-binary:
runs-on: ubuntu-latest

strategy:
matrix:
goos: [linux, windows, darwin] # 需要打包的系统
goarch: ["386",amd64,arm64] # 需要打包的架构
exclude: # 排除某些平台和架构
- goarch: arm64
goos: windows
- goarch: "386"
goos: darwin
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.2.2


- name: Checkout code
uses: actions/checkout@v3

- name: Testpwd
run: go env -w GO111MODULE=on

- name: GetEnv
run: go env

- name: Build for Windows
run: GOOS=windows GOARCH=amd64 go build -o gofreeproxy-windows-amd64.exe

- name: Build for Linux
run: GOOS=linux GOARCH=amd64 go build -o gofreeproxy-linux-amd64

- name: Build for macOS
run: GOOS=darwin GOARCH=amd64 go build -o gofreeproxy-darwin-amd64
- name: Zip binaries
run: |
zip gofreeproxy-windows-amd64.zip gofreeproxy-windows-amd64.exe
zip gofreeproxy-linux-amd64.zip gofreeproxy-linux-amd64
zip gofreeproxy-darwin-amd64.zip gofreeproxy-darwin-amd64

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Windows binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./gofreeproxy-windows-amd64.zip
asset_name: gofreeproxy-windows-amd64.zip
asset_content_type: application/zip

- name: Upload Linux binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./gofreeproxy-linux-amd64.zip
asset_name: gofreeproxy-linux-amd64.zip
asset_content_type: application/zip

- name: Upload macOS binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
- uses: wangyoucao577/go-release-action@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./gofreeproxy-darwin-amd64.zip
asset_name: gofreeproxy-darwin-amd64.zip
asset_content_type: application/zip
github_token: ${{ secrets.GITHUB_TOKEN }} # 一个默认的变量,用来实现往 Release 中添加文件
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: 1.18 # 可以指定编译使用的 Golang 版本
binary_name: "Gofreeproxy-${{ matrix.goos }}-${{ matrix.goarch }}" # 可以指定二进制文件的名称
asset_name: "Gofreeproxy-${{ matrix.goos }}-${{ matrix.goarch }}"
# extra_files: README.md # 需要包含的额外文件
sha256sum: TRUE
project_path: ./main
# pre_command: rm ./main/clash.go
# build_command:
ldflags: -s -w
84 changes: 0 additions & 84 deletions main/clash.go

This file was deleted.

4 changes: 2 additions & 2 deletions main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ var (
func main() {
fmt.Println(logo)
flag.BoolVar(&Fofa, "fofa", false, "\n使用-fofa参数可从fofa收集资产获取公开代理使用")
flag.BoolVar(&Hunter, "hunter", false, "\n使用-hunter参数可从fofa收集资产获取公开代理使用")
flag.BoolVar(&Quake, "quake", false, "\n使用-quake参数可从hunter收集资产获取公开代理使用")
flag.BoolVar(&Hunter, "hunter", false, "\n使用-hunter参数可从hunter收集资产获取公开代理使用")
flag.BoolVar(&Quake, "quake", false, "\n使用-quake参数可从quake收集资产获取公开代理使用")
flag.StringVar(&Host, "h", "127.0.0.1", "\n使用自定义本地服务监听地址,默认为127.0.0.1")
flag.BoolVar(&Renew, "renew", false, "\n当启用-fofa或-quake或-hunter参数时是否对现有proxy.txt进行重写,默认为否")
flag.BoolVar(&File, "f", false, "\n使用-f参数可读取当前目录下的proxy.txt,获取其中的代理使用")
Expand Down