Skip to content

Commit

Permalink
UPDATE workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
iotames committed Apr 28, 2024
1 parent 9d8658a commit 54f5236
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 42 deletions.
102 changes: 62 additions & 40 deletions .github/workflows/release_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
tags:
- "v*"

permissions: # 需要设置写权限才能自动发布
contents: write

jobs:
create_release:
if: github.event_name == 'push'
Expand All @@ -32,67 +35,86 @@ jobs:

build:
name: Build App
# if: github.event_name == 'release'
# needs: create_release
strategy:
matrix:
goos: [windows, linux, darwin]

permissions: # 需要设置写权限才能自动发布
contents: write
os: [ ubuntu-latest, macos-latest ]

runs-on: ubuntu-latest
env:
GOOS: ${{ matrix.goos }}
CGO_ENABLED: 0
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Go
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22.x'

- name: Install dependencies

- name: Setup Docker
if: runner.os == 'Linux'
uses: docker-practice/actions-setup-docker@master

- name: Setup toolchain
if: runner.os == 'Linux'
run: |
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
sudo apt-get update -y
sudo apt-get install -y gcc libgl1-mesa-dev xorg-dev
go mod tidy
sudo apt-get update
sudo apt-get install -y build-essential libgl1-mesa-dev xorg-dev libgtk-3-dev
go install fyne.io/fyne/v2/cmd/fyne@latest
go install github.com/fyne-io/fyne-cross@latest
- name: Get File Name
id: get_filename
- name: Build for Linux
if: runner.os == 'Linux'
run: |
export _NAME=DownUtils-${{ matrix.goos }}.tar.gz
echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME"
echo "ASSET_NAME=$_NAME" >> $GITHUB_OUTPUT
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
go env -w GO111MODULE=on
go mod tidy
go build -ldflags="-s -w"
chmod +x downutils
tar zcf downutils-linux-x86_64.tar.gz downutils
- name: Build for Windows
if: runner.os == 'Linux'
run: |
fyne-cross windows --arch=amd64 --icon resource/images/logo.png
cd fyne-cross/bin/windows-amd64
zip -r $GITHUB_WORKSPACE/downutils-windows-x86_64.zip ./*
- name: Build
- name: Build for macOS
if: runner.os == 'macOS'
run: |
GOPATH=$(go env GOPATH)
ls $GOPATH/bin
$(GOPATH)/bin/fyne package -os ${{ matrix.goos }} -icon resource/images/logo.png
ls *.exe *.tar*
- name: Package
run: tar zcvf ${{ steps.get_filename.outputs.ASSET_NAME }} *.exe *.tar*
go install fyne.io/fyne/v2/cmd/fyne@latest
fyne package --icon resource/images/logo.png --release
zip -r downutils-macOS-x86_64.zip downutils.app
# - name: Get File Name
# id: get_filename
# run: |
# export _NAME=downutils-
# echo "GOOS: $GOOS, GOARCH: $GOARCH, RELEASE_NAME: $_NAME"
# echo "ASSET_NAME=$_NAME" >> $GITHUB_OUTPUT
# echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV

# 上传附件
- name: Upload file to Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get_filename.outputs.ASSET_NAME }}
path: ${{ steps.get_filename.outputs.ASSET_NAME }}
name: build-artifact-${{ matrix.os }}
path: |
downutils-linux-x86_64.tar.gz
downutils-windows-x86_64.zip
downutils-macOS-x86_64.zip
- name: Upload files to GitHub release
uses: svenstaro/upload-release-action@v2
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: ./${{ steps.get_filename.outputs.ASSET_NAME }}
tag: ${{ github.ref }}
overwrite: true
files: |
downutils-linux-x86_64.tar.gz
downutils-windows-x86_64.zip
downutils-macOS-x86_64.zip
# uses: svenstaro/upload-release-action@v2
# with:
# repo_token: ${{ secrets.GITHUB_TOKEN }}
# file_glob: true
# file: ./${{ steps.get_filename.outputs.ASSET_NAME }}
# tag: ${{ github.ref }}
# overwrite: true

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ go.sum
*.zip
*.tar.gz
*.tar.xz
runtime/
runtime/
fyne-cross/
2 changes: 1 addition & 1 deletion FyneApp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Icon = "resource/images/logo.png"
Name = "DownUtils"
ID = "io.github.iotames.downutils"
Build = 2
Build = 3

0 comments on commit 54f5236

Please sign in to comment.