Skip to content

ci(release): simplify bundle command in release workflow #26

ci(release): simplify bundle command in release workflow

ci(release): simplify bundle command in release workflow #26

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: [linux, windows]
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: |
outfile=${{ matrix.package }}
if [ "${{ matrix.os }}" = "windows" ]; then
outfile="${outfile}.exe"
fi
mkdir -p build/
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -v \
-o "build/$outfile" \
./cmd/${{ matrix.package }}
- name: Bundle
run: 7z a -tzip "${{ matrix.package }}-${{ matrix.os }}-${{ matrix.arch }}.zip" build/${{ 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: ${{ matrix.package }}-${{ matrix.os }}-${{ matrix.arch }}.zip
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/}"
gh release create "$tagname" -t "$tagname" build/*