Skip to content

Add github action for automated build and publish #2

Add github action for automated build and publish

Add github action for automated build and publish #2

Workflow file for this run

name: Publish
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
workflow_dispatch:
inputs:
version:
description: Version for release and program help
required: true
permissions:
contents: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- id: version
run: |
str=$(echo ${{ inputs.version || github.ref_name }} | cut -dv -f2)
echo "version=$version" >> $GITHUB_OUTPUT
- id: create
name: Create release
uses: softprops/action-gh-release@v2
with:
name: imgchop ${{ steps.version.outputs.version }}
outputs:
upload_url: ${{ steps.create.outputs.upload_url }}
version: ${{ steps.create.outputs.version }}
upload:
name: Upload asset (${{ matrix.target.os }})
needs: release
runs-on: ubuntu-latest
strategy:
matrix:
target:
- os: windows
arch: amd64
output: imgchop.exe
- os: linux
arch: amd64
output: imgchop
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.x"
- run: go get .
- run: go build -ldflags "-X main.version=${{ needs.release.outputs.version }}" -o "./build/${{ matrix.target.output }}"
env:
GOOS: ${{ matrix.target.os }}
GOARCH: ${{ matrix.target.arch }}
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_name: ${{ matrix.target.output }}
asset_path: ./build/${{ matrix.target.output }}
asset_content_type: application/octet-stream