picoclaw/.github/workflows/nightly.yml
Hua Audio 9a35f69323
Update .github/workflows/nightly.yml
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-08 01:56:32 +01:00

135 lines
3.7 KiB
YAML

name: Nightly Build
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
contents: read
jobs:
generate-version:
name: Generate Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Generate version
id: version
run: |
DATE=$(date +%Y%m%d)
SHA=$(git rev-parse --short HEAD)
BASE_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
VERSION="${BASE_VERSION}-nightly-${DATE}-${SHA}"
TAG="nightly-${DATE}-${SHA}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
build:
name: Build
runs-on: ubuntu-latest
needs: generate-version
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Build
run: make build-all VERSION=${{ needs.generate-version.outputs.version }}
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: picoclaw-binaries
path: build
build-docker:
name: Build Docker
runs-on: ubuntu-latest
needs: generate-version
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Generate lowercase repo
id: repo
run: echo "repo=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
push: true
tags: |
ghcr.io/${{ steps.repo.outputs.repo }}:${{ needs.generate-version.outputs.tag }}
ghcr.io/${{ steps.repo.outputs.repo }}:${{ needs.generate-version.outputs.version }}
ghcr.io/${{ steps.repo.outputs.repo }}:nightly
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64,linux/riscv64
release:
name: Release
runs-on: ubuntu-latest
needs: [generate-version, build]
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download artifacts
uses: actions/download-artifact@v6
with:
name: picoclaw-binaries
path: ./build
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ needs.generate-version.outputs.tag }}"
TITLE="${{ needs.generate-version.outputs.version }}"
NOTES="Nightly build for ${{ needs.generate-version.outputs.version }}"
if gh release view "$TAG" >/dev/null 2>&1; then
echo "Release $TAG already exists, updating metadata and assets..."
gh release edit "$TAG" \
--title "$TITLE" \
--notes "$NOTES"
gh release upload "$TAG" build/* --clobber
else
echo "Creating new release $TAG..."
gh release create "$TAG" \
--title "$TITLE" \
--notes "$NOTES" \
build/*
fi