mirror of
https://github.com/compute-blade-community/compute-blade-agent.git
synced 2026-04-16 15:35:42 +02:00
148 lines
3.5 KiB
YAML
148 lines
3.5 KiB
YAML
name: Go Release - Publish
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
permissions: write-all
|
|
|
|
jobs:
|
|
test:
|
|
name: Unit Tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# Checkout code
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
# Set up Go environment
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: "go.mod"
|
|
cache: true
|
|
cache-dependency-path: "**/*.sum"
|
|
|
|
- name: Run tests
|
|
run: go test -cover -coverprofile=coverage.txt ./...
|
|
|
|
- name: Archive code coverage results
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: code-coverage
|
|
path: "coverage.txt"
|
|
if-no-files-found: error
|
|
|
|
# Release-please for auto-updated PRs
|
|
release-please:
|
|
name: Release Please
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- test
|
|
|
|
steps:
|
|
- uses: googleapis/release-please-action@v3
|
|
id: release-please
|
|
with:
|
|
release-type: simple # actual releasing is handled by goreleaser
|
|
package-name: compute-blade-agent
|
|
bump-minor-pre-major: true
|
|
bump-patch-for-minor-pre-major: true
|
|
outputs:
|
|
release_created: ${{ steps.release-please.outputs.release_created }}
|
|
|
|
tinygo:
|
|
name: Build FanUnit Firmware
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- release-please
|
|
|
|
if: needs.release-please.outputs.release_created
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: "go.mod"
|
|
cache-dependency-path: "**/*.sum"
|
|
cache: true
|
|
|
|
# Setup tinygo
|
|
- uses: acifani/setup-tinygo@v2
|
|
with:
|
|
tinygo-version: "0.37.0"
|
|
|
|
# Build fanunit firmware
|
|
- name: Build FanUnit Firmware
|
|
run: make build-fanunit
|
|
|
|
- name: Archive FanUnit Firmware
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: fanunit.uf2
|
|
path: "fanunit.uf2"
|
|
|
|
# Goreleaser for binary releases / GH release
|
|
goreleaser:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- release-please
|
|
- tinygo
|
|
|
|
if: needs.release-please.outputs.release_created
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
# Install cosign
|
|
- name: Install Cosign
|
|
uses: sigstore/cosign-installer@v3
|
|
|
|
# Install GoLang
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: "go.mod"
|
|
cache-dependency-path: "**/*.sum"
|
|
cache: true
|
|
|
|
# Setup docker buildx
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: "Login to GitHub Container Registry"
|
|
uses: docker/login-action@v4
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{github.actor}}
|
|
password: ${{secrets.GITHUB_TOKEN}}
|
|
|
|
# Download FanUnit Firmware
|
|
- name: Download fanunit firmware
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
pattern: fanunit.uf2
|
|
|
|
# Run goreleaser
|
|
- name: Run GoReleaser
|
|
uses: goreleaser/goreleaser-action@v7
|
|
with:
|
|
version: "~> v2"
|
|
args: release --clean
|
|
env:
|
|
COSIGN_YES: "true"
|
|
KO_DOCKER_REPO: ghcr.io/${{ github.repository }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|