Skip to content

Commit

Permalink
feat: 增加平台构建
Browse files Browse the repository at this point in the history
  • Loading branch information
Licoy committed Jun 19, 2022
1 parent dc5f75d commit cd4f8e1
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 26 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build for Linux

on:
push:
tags:
- v*

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.4

- name: Get dependencies
run: sudo apt update && sudo apt install xorg-dev

- name: Package
run: CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o Fetch-Github-Hosts

- name: Compress
uses: a7ul/[email protected]
id: compress
with:
command: c
files: |
LICENSE
README.md
Fetch-Github-Hosts
outPath: fetch-github-hosts_${{ env.RELEASE_VERSION }}_linux_amd64.tar.gz

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
append_body: true
files: fetch-github-hosts_${{ env.RELEASE_VERSION }}_linux_amd64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/build-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build for MacOS

on:
push:
tags:
- v*

jobs:
build:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.4

- name: Install fyne
run: go install fyne.io/fyne/v2/cmd/fyne

- name: Package for MacOS
run: fyne package --release -os darwin

- name: Compress
uses: a7ul/[email protected]
id: compress
with:
command: c
files: |
LICENSE
README.md
Fetch-Github-Hosts.app
outPath: fetch-github-hosts_${{ env.RELEASE_VERSION }}_macOS_amd64.tar.gz

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
append_body: true
files: fetch-github-hosts_${{ env.RELEASE_VERSION }}_macOS_amd64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build for Windows

on:
push:
tags:
- v*

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17.4

- name: Get dependencies
run: sudo apt update && sudo apt install gcc xorg-dev gcc-mingw-w64

- name: Package
run: CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ GOOS=windows GOARCH=amd64 go build -ldflags " -H=windowsgui -s -w" -o Fetch-Github-Hosts.exe

- name: Compress
uses: a7ul/[email protected]
id: compress
with:
command: c
files: |
LICENSE
README.md
Fetch-Github-Hosts.exe
outPath: fetch-github-hosts_${{ env.RELEASE_VERSION }}_windows_amd64.tar.gz

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
append_body: true
files: fetch-github-hosts_${{ env.RELEASE_VERSION }}_windows_amd64.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 0 additions & 26 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit cd4f8e1

Please sign in to comment.