Skip to content

ci(release): Enable tag-based workflow trigger and manual dispatch #23

ci(release): Enable tag-based workflow trigger and manual dispatch

ci(release): Enable tag-based workflow trigger and manual dispatch #23

Workflow file for this run

name: Build and Release
on:
# Trigger the workflow on a push with a tag starting with 'v'
push:
tags:
- 'v*'
# Allow manual trigger
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
go-version: ["1.22.x"]
arch: [amd64]
package: [flower, flower-tui]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Go environment
uses: actions/setup-go@v5
with:
cache: true
go-version: ${{ matrix.go-version }}
- name: Install dependencies
run: go get -v -t -d ./...
- name: Build ${{ matrix.package }} for ${{ matrix.os }} (${{ matrix.arch }})
run: |
mkdir -p build/
GOOS=$(if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then echo "linux"; else echo "windows"; fi) GOARCH=${{ matrix.arch }} go build -v \
-o build/${{ matrix.package }} \
./cmd/${{ matrix.package }}
- name: Archive build artifact
uses: actions/upload-artifact@v4
with:
compression-level: 0
if-no-files-found: error
name: ${{ matrix.package }}-${{ matrix.os }}-${{ matrix.arch }}
path: build/${{ matrix.package }}
release:
name: Release
permissions:
contents: write
runs-on: ubuntu-latest
needs: [build]
steps:
# Without this, "gh" explodes spectacularily
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: build/
- name: Upload Binaries
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tagname="${GITHUB_REF#refs/tags/}"
echo "Tag name is $tagname"
ls -lR build/*
echo "Uploading release assets..."
files=$(for f in build/*; do
echo -n " $f"
done)
echo "Files are $files"
GH_DEBUG=api gh release create "$tagname" -t "$tagname" $files