Skip to content

Commit

Permalink
Update go_build_release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
gek64 authored Dec 8, 2023
1 parent 00f71f4 commit c52d6b6
Showing 1 changed file with 34 additions and 63 deletions.
97 changes: 34 additions & 63 deletions .github/workflows/go_build_release.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
name: Go Build and Release
name: Go Build and Release and Clean

on:
push:
branches: [ main ]
branches:
- main
- master
paths-ignore:
- 'docs/**'
- '.github/**'
- '**.md'
- 'LICENSE'
pull_request:
branches: [ main ]
branches:
- main
- master
paths-ignore:
- 'docs/**'
- '.github/**'
- '**.md'
- 'LICENSE'
workflow_dispatch:
inputs:
version:
description: 'version'
tag:
description: 'tag'
required: false
default: 'latest'
# use ${{ github.event.inputs.version }}
# use ${{ github.event.inputs.tag }}

jobs:
build:
job1:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -33,36 +37,7 @@ jobs:
- name: Setup golang
uses: actions/setup-go@v4
with:
go-version: '^1.20'

- name: Build
run: |
# 下载依赖
git clone https://github.com/gek64/gek.git
ln -s ${{ github.workspace }}/gek ../gek
mkdir -p bin
# 编译批量编译程序
git clone https://github.com/gek64/gobuilder.git
cd gobuilder
go mod tidy
go build -v -trimpath -ldflags "-s -w" -o "${{ github.workspace }}/gobuilder_runner"
chmod +x "${{ github.workspace }}/gobuilder_runner"
cd ${{ github.workspace }}
# 编译所有支持的架构/系统对
go mod tidy
"${{ github.workspace }}/gobuilder_runner" -main -d bin
# 显示文件路径(debug)
# ls .. -R -las
# 获取sha256 checksum
sha256sum bin/* > bin/SHA256SUMS.txt
# 获取版本信息
echo "$(go run . -v)" > bin/version.txt
go-version: 'stable'

- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@v0.3.2
Expand All @@ -72,42 +47,38 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: build_files
path: bin/*

release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v3
with:
name: build_files
path: bin

- name: Read version
- name: Build
run: |
# 编译gobd
git clone https://github.com/gek64/gobd.git
cd gobd
go build -o "${{ github.workspace }}/gobd_runner"
chmod +x "${{ github.workspace }}/gobd_runner"
# 编译程序
cd ${{ github.workspace }}
# 获取版本信息
echo "VERSION=$(cat bin/version.txt)" >> $GITHUB_ENV
rm -rf bin/version.txt
echo "VERSION=$(go run . -v)" >> $GITHUB_ENV
# 批量编译
go mod tidy
"${{ github.workspace }}/gobd_runner" -main -d bin -no_debug -no_cgo
"${{ github.workspace }}/gobd_runner" -os linux -arch mipsle -n ${{ github.event.repository.name }}-softfloat -d bin -no_debug -no_cgo -envs 'GOMIPS=softfloat'
# 获取sha256 checksum
sha256sum bin/* > bin/SHA256SUMS.txt
- name: Release
uses: ncipollo/release-action@v1
with:
artifacts: "bin/*"
tag: ${{ env.VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: true
removeArtifacts: true
replacesArtifacts: true

delete-artifacts:
runs-on: ubuntu-latest
needs: release
steps:
- name: Remove old artifacts
uses: c-hive/gha-remove-artifacts@v1
with:
Expand Down

0 comments on commit c52d6b6

Please sign in to comment.