Skip to content

Release Tray Binary

Release Tray Binary #5

Workflow file for this run

name: Release Tray Binary
on:
workflow_run:
workflows: ["Release"]
types: [completed]
permissions:
contents: write
jobs:
build-tray:
if: github.event.workflow_run.conclusion == 'success'
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
cc: gcc
- os: macos-latest
goos: darwin
goarch: arm64
cc: ""
- os: windows-latest
goos: windows
goarch: amd64
cc: ""
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Extract release tag
id: tag
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CANDIDATE="${{ github.event.workflow_run.head_branch }}"
if [[ ! "$CANDIDATE" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
CANDIDATE=$(gh release list --limit 1 --json tagName -q '.[0].tagName')
fi
if [[ ! "$CANDIDATE" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "::error::Could not determine release tag"
exit 1
fi
echo "TAG=$CANDIDATE" >> "$GITHUB_ENV"
echo "VERSION=${CANDIDATE#v}" >> "$GITHUB_ENV"
- uses: actions/setup-go@v5
with:
go-version-file: cmd/sap-devs-tray/go.mod
- name: Install Linux amd64 deps
if: matrix.goos == 'linux' && matrix.goarch == 'amd64'
run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev
- name: Prepare tray build assets
run: cp internal/geo/cities.json cmd/sap-devs-tray/data/cities.json
- name: Build
working-directory: cmd/sap-devs-tray
shell: bash
env:
CGO_ENABLED: "1"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CC: ${{ matrix.cc }}
run: |
EXT=""
if [ "${{ matrix.goos }}" = "windows" ]; then EXT=".exe"; fi
go build -ldflags "-X main.version=${VERSION}" -o "sap-devs-tray${EXT}" .
- name: Package
shell: bash
run: |
ASSET="sap-devs-tray_${VERSION}_${{ matrix.goos }}_${{ matrix.goarch }}"
if [ "${{ matrix.goos }}" = "windows" ]; then
7z a "${ASSET}.zip" ./cmd/sap-devs-tray/sap-devs-tray.exe
else
tar czf "${ASSET}.tar.gz" -C cmd/sap-devs-tray sap-devs-tray
fi
- name: Generate checksum
shell: bash
run: |
ASSET="sap-devs-tray_${VERSION}_${{ matrix.goos }}_${{ matrix.goarch }}"
if [ "${{ matrix.goos }}" = "windows" ]; then
FILE="${ASSET}.zip"
else
FILE="${ASSET}.tar.gz"
fi
if command -v sha256sum &>/dev/null; then
sha256sum "${FILE}" > "${FILE}.sha256"
else
shasum -a 256 "${FILE}" > "${FILE}.sha256"
fi
- name: Upload to Release
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ASSET="sap-devs-tray_${VERSION}_${{ matrix.goos }}_${{ matrix.goarch }}"
if [ "${{ matrix.goos }}" = "windows" ]; then
gh release upload "$TAG" "${ASSET}.zip" "${ASSET}.zip.sha256" --clobber
else
gh release upload "$TAG" "${ASSET}.tar.gz" "${ASSET}.tar.gz.sha256" --clobber
fi
aggregate-checksums:
needs: build-tray
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract release tag
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CANDIDATE="${{ github.event.workflow_run.head_branch }}"
if [[ ! "$CANDIDATE" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
CANDIDATE=$(gh release list --limit 1 --json tagName -q '.[0].tagName')
fi
echo "TAG=$CANDIDATE" >> "$GITHUB_ENV"
echo "VERSION=${CANDIDATE#v}" >> "$GITHUB_ENV"
- name: Download per-artifact checksums
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p checksums
for suffix in linux_amd64.tar.gz darwin_arm64.tar.gz windows_amd64.zip; do
FILE="sap-devs-tray_${VERSION}_${suffix}.sha256"
gh release download "$TAG" -p "${FILE}" -D checksums || true
done
- name: Aggregate into tray-checksums.txt
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COUNT=$(ls checksums/*.sha256 2>/dev/null | wc -l)
if [ "$COUNT" -ne 3 ]; then
echo "::warning::Expected 3 checksums, got $COUNT"
fi
cat checksums/*.sha256 > tray-checksums.txt
gh release upload "$TAG" tray-checksums.txt --clobber