Skip to content

Merge pull request #103 from gruntwork-io/add-gitclone-repo-owner-out… #78

Merge pull request #103 from gruntwork-io/add-gitclone-repo-owner-out…

Merge pull request #103 from gruntwork-io/add-gitclone-repo-owner-out… #78

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*'
- 'beta*'
workflow_dispatch:
permissions:
contents: write
jobs:
build-web:
name: Build Web Frontend
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.10
- name: Install web dependencies
working-directory: ./web
run: bun install
- name: Build web frontend
working-directory: ./web
env:
VITE_MIXPANEL_TOKEN: ${{ secrets.MIXPANEL_TOKEN }}
run: bun run build
- name: Upload web dist artifact
uses: actions/upload-artifact@v4
with:
name: web-dist
path: web/dist/
retention-days: 1
build-binaries:
name: Build Binaries
needs: build-web
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: linux
goarch: '386'
- goos: linux
goarch: arm
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: windows
goarch: amd64
- goos: windows
goarch: '386'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper version info
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.26.1'
- name: Download web dist artifact
uses: actions/download-artifact@v4
with:
name: web-dist
path: web/dist/
- name: Get version info
id: version
run: |
# Get version from tag or use dev
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION="dev"
fi
# Get git commit hash
GIT_COMMIT=$(git rev-parse --short HEAD)
# Get build date
BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "git_commit=$GIT_COMMIT" >> $GITHUB_OUTPUT
echo "build_date=$BUILD_DATE" >> $GITHUB_OUTPUT
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
MIXPANEL_TOKEN: ${{ secrets.MIXPANEL_TOKEN }}
run: |
# Set binary name based on platform
BINARY_NAME="runbooks_${{ matrix.goos }}_${{ matrix.goarch }}"
if [ "${{ matrix.goos }}" = "windows" ]; then
BINARY_NAME="${BINARY_NAME}.exe"
fi
# Build with version info and telemetry token injected via ldflags
go build \
-ldflags="-s -w -X 'runbooks/cmd.Version=${{ steps.version.outputs.version }}' -X 'runbooks/cmd.GitCommit=${{ steps.version.outputs.git_commit }}' -X 'runbooks/cmd.BuildDate=${{ steps.version.outputs.build_date }}' -X 'runbooks/api/telemetry.MixpanelToken=${MIXPANEL_TOKEN}'" \
-o "$BINARY_NAME" \
.
# Verify the binary was created
ls -lh "$BINARY_NAME"
# Create output directory
mkdir -p dist
mv "$BINARY_NAME" dist/
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: runbooks-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/
retention-days: 7
sign-macos-binaries:
name: Sign MacOS Binaries
needs: build-binaries
uses: ./.github/workflows/sign-macos.yml
secrets: inherit
create-checksums:
name: Create Checksums
needs: [build-binaries, sign-macos-binaries]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all binary artifacts
uses: actions/download-artifact@v4
with:
pattern: runbooks-*
path: binaries/
merge-multiple: true
- name: Generate SHA256 checksums
run: |
cd binaries
sha256sum * > SHA256SUMS
cat SHA256SUMS
- name: Upload checksums artifact
uses: actions/upload-artifact@v4
with:
name: checksums
path: binaries/SHA256SUMS
retention-days: 7
create-release:
name: Create GitHub Release
needs: [create-checksums, sign-macos-binaries]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all binary artifacts
uses: actions/download-artifact@v4
with:
pattern: runbooks-*
path: binaries/
merge-multiple: true
- name: Download checksums
uses: actions/download-artifact@v4
with:
name: checksums
path: binaries/
- name: List artifacts
run: |
echo "Files to be released:"
ls -lh binaries/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: binaries/*
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-homebrew:
name: Update Homebrew Formula
needs: create-release
uses: ./.github/workflows/update-homebrew.yml
with:
tag: ${{ github.ref_name }}
secrets: inherit