Go #28
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go | |
on: | |
workflow_dispatch: | |
release: | |
types: [created] | |
env: | |
PLUGIN_NAME: obsidian-image-api-gateway | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [linux, windows] # 需要打包的系统 | |
goarch: [amd64, arm64] # 需要打包的架构 | |
exclude: # 排除某些平台和架构 | |
- goarch: arm64 | |
goos: windows | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v5.1.0 | |
with: | |
go-version: "1.23" | |
- 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 | |
- name: Get Tag Version | |
run: echo "LDFLAGS=-ldflags \"-X global.GitTag=${{ env.TAG_VERSION }} -X global.BuildTime=${{ env.TIME }}\"" >> $GITHUB_ENV | |
- name: build | |
run: | | |
CGO_ENABLED=1 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build ${{ env.LDFLAGS }} -o ./build/${{ matrix.goos }}-${{ matrix.goarch }}/image-api | |
cp ./config/config.yaml ./build/${{ matrix.goos }}-${{ matrix.goarch }}/config | |
- name: GZip file | |
id: gzip | |
run: | | |
tar -czvf ./build/${{ env.PLUGIN_NAME }}-${{ env.TAG_VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz -C ./build/${{ matrix.goos }}-${{ matrix.goarch }}/ . | |
- name: Upload GZip file | |
id: upload-macos | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./build/${{ env.PLUGIN_NAME }}-${{ env.TAG_VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | |
asset_name: ${{ env.PLUGIN_NAME }}-${{ env.TAG_VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz | |
asset_content_type: application/gzip |