Skip to content

ci: update release workflow to use GH_TOKEN and enable debug logging #22

ci: update release workflow to use GH_TOKEN and enable debug logging

ci: update release workflow to use GH_TOKEN and enable debug logging #22

Workflow file for this run

name: Go CI
on:
# Trigger the workflow on a push with a tag starting with 'v'
push:
tags:
- 'v*'
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
go-version: ["1.22.x"]
arch: [amd64]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Go environment
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Install dependencies
run: go get -v -t -d ./...
- name: Build binary
run: |
mkdir -p build/${{ matrix.os }}-${{ matrix.arch }}
GOOS=$(if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then echo "linux"; else echo "windows"; fi) GOARCH=${{ matrix.arch }} go build -v \
-o build/${{ matrix.os }}-${{ matrix.arch }}/app \
./cmd/flower
- name: Archive build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.arch }}
path: build/${{ matrix.os }}-${{ matrix.arch }}/app
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:
path: build/
- name: Upload Binaries
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tagname="${GITHUB_REF#refs/tags/}"
echo "Tag name is $tagname"
echo "Uploading release assets..."
ls -lR build/*
files=$(for f in build/*; do
outfile=$(echo $f | sed -e s/build\\/// -e s/latest-//)
echo -n " $f/app#$outfile"
if [[ "$f" == *windows* ]]; then
echo -n ".exe"
fi
done)
echo "Files are $files"
GH_DEBUG=api gh release create "$tagname" -t "$tagname" $files