Skip to content

Go

Go #25

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
workflow_dispatch:
release:
types: [created]
env:
PLUGIN_NAME: obsidian-image-api-gateway
jobs:
build-go-binary:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin] # 需要打包的系统
goarch: [amd64, arm64] # 需要打包的架构
exclude: # 排除某些平台和架构
- goarch: arm64
goos: windows
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set Time
run: echo "TIME=`echo $(TZ='Asia/Shanghai' date +'%FT%T%z')`" >> $GITHUB_ENV
- name: Get Tag Version
run: echo "TAG_VERSION=`echo $(git describe --tags --abbrev=0)`" >> $GITHUB_ENV
- uses: haierkeys/go-release-action@v1.53
with:
github_token: ${{ secrets.GITHUB_TOKEN }} # 一个默认的变量,用来实现往 Release 中添加文件
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
ldflags: -X global.GitTag=${{ env.TAG_VERSION }} -X global.BuildTime=${{ env.TIME }}
goversion: 1.23 # 可以指定编译使用的 Golang 版本
binary_name: "image-api" # 可以指定二进制文件的名称
compress_assets: zip
extra_files: README.md readme-zh.md config/config.yaml # 需要包含的额外文件