Skip to content

Build and Release

Build and Release #4

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: build-${{ matrix.os }}-${{ matrix.arch }}
path: build/${{ matrix.os }}-${{ matrix.arch }}/app
release:
name: Release
permissions:
contents: write
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-ubuntu-latest-amd64
path: build/linux-amd64
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-windows-latest-amd64
path: build/windows-amd64
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: true
- name: Upload Linux Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/linux-amd64/app
asset_name: flower-linux-amd64
asset_content_type: application/octet-stream
- name: Upload Windows Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/windows-amd64/app
asset_name: flower-windows-amd64.exe
asset_content_type: application/octet-stream