Skip to content

Commit 5546cf3

Browse files
authored
Merge pull request #18 from OpenCHAMI/chore/add-build-automation
Add build automation with Makefile and update github workflows
2 parents f6653eb + 12c5408 commit 5546cf3

95 files changed

Lines changed: 1388 additions & 289 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.fabrica.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-FileCopyrightText: 2026 OpenCHAMI Contributors
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
project:
6+
name: fru-tracker
7+
module: github.com/example/fru-tracker
8+
description: OpenCHAMI FRU tracker service with Fabrica-generated REST APIs for hardware discovery and inventory
9+
created: 2026-02-26T11:09:26-08:00
10+
features:
11+
validation:
12+
enabled: true
13+
mode: strict
14+
events:
15+
enabled: true
16+
bus_type: memory
17+
conditional:
18+
enabled: true
19+
etag_algorithm: sha256
20+
auth:
21+
enabled: false
22+
security:
23+
authn:
24+
enabled: false
25+
authz:
26+
enabled: false
27+
mode: enforce
28+
storage:
29+
enabled: true
30+
type: ent
31+
metrics:
32+
enabled: false
33+
generation:
34+
handlers: true
35+
storage: true
36+
client: true
37+
openapi: true
38+
events: true
39+
middleware: true
40+
reconciliation: true

.github/workflows/PRBuild.yaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Copyright © 2026 OpenCHAMI a Series of LF Projects, LLC
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
name: Build each PR for testing and validation
6+
7+
on:
8+
pull_request:
9+
branches:
10+
- main
11+
types: [opened, synchronize, reopened, edited]
12+
workflow_dispatch:
13+
inputs:
14+
pr_number:
15+
description: 'PR Number to build (optional, for manual PR builds)'
16+
required: false
17+
type: string
18+
19+
permissions: write-all # Necessary for the generate-build-provenance action with containers
20+
21+
jobs:
22+
23+
build:
24+
25+
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- name: Set up latest stable Go
30+
uses: actions/setup-go@v6.4.0
31+
with:
32+
go-version: stable
33+
- name: Set up QEMU
34+
uses: docker/setup-qemu-action@v3
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v3
37+
with:
38+
driver-opts: |
39+
image=moby/buildkit:master
40+
network=host
41+
- name: Docker Login
42+
uses: docker/login-action@v3
43+
with:
44+
registry: ghcr.io
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
- name: Checkout
48+
uses: actions/checkout@v6.0.2
49+
with:
50+
fetch-tags: 1
51+
fetch-depth: 0
52+
# Set environment variables required by GoReleaser
53+
- name: Set build environment variables
54+
run: |
55+
echo "GIT_STATE=$(if git diff-index --quiet HEAD --; then echo 'clean'; else echo 'dirty'; fi)" >> $GITHUB_ENV
56+
echo "BUILD_HOST=$(hostname)" >> $GITHUB_ENV
57+
echo "GO_VERSION=$(go version | awk '{print $3}')" >> $GITHUB_ENV
58+
echo "BUILD_USER=$(whoami)" >> $GITHUB_ENV
59+
echo "CGO_ENABLED=0" >> $GITHUB_ENV
60+
echo "IS_PR_BUILD=true" >> $GITHUB_ENV
61+
62+
- name: Docker Login
63+
uses: docker/login-action@v3
64+
with:
65+
registry: ghcr.io
66+
username: ${{ github.actor }}
67+
password: ${{ secrets.GITHUB_TOKEN }}
68+
69+
- name: Create Tag for PR
70+
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.pr_number != '')
71+
run: |
72+
git config --global user.name "github-actions[bot]"
73+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
74+
PR_NUM="${{ github.event.number }}"
75+
if [[ "${{ inputs.pr_number }}" != "" ]]; then
76+
PR_NUM="${{ inputs.pr_number }}"
77+
fi
78+
git tag -f -a pr-${PR_NUM} -m "PR Release"
79+
80+
- name: Build/Push container with goreleaser
81+
uses: goreleaser/goreleaser-action@v6
82+
env:
83+
GITHUB_TOKEN: ${{ github.token }}
84+
with:
85+
version: '~> 2'
86+
args: release --clean --skip=announce,validate,archive
87+
id: goreleaser
88+
- name: Process goreleaser output
89+
id: process_goreleaser_output
90+
run: |
91+
echo "const fs = require('fs');" > process.js
92+
echo 'const artifacts = ${{ steps.goreleaser.outputs.artifacts }}' >> process.js
93+
echo "const firstNonNullDigest = artifacts.find(artifact => artifact.extra && artifact.extra.Digest != null)?.extra.Digest;" >> process.js
94+
echo "console.log(firstNonNullDigest);" >> process.js
95+
echo "fs.writeFileSync('digest.txt', firstNonNullDigest);" >> process.js
96+
node process.js
97+
echo "digest=$(cat digest.txt)" >> $GITHUB_OUTPUT
98+
- name: Attest Binaries
99+
uses: actions/attest-build-provenance@v4.1.0
100+
with:
101+
subject-path: dist/**/fru-tracker*
102+
- name: generate build provenance
103+
uses: actions/attest-build-provenance@v4.1.0
104+
with:
105+
subject-name: ghcr.io/openchami/fru-tracker
106+
subject-digest: ${{ steps.process_goreleaser_output.outputs.digest }}
107+
push-to-registry: true

.github/workflows/REUSE.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright © 2026 OpenCHAMI a Series of LF Projects, LLC
2+
# SPDX-FileCopyrightText: 2020 Free Software Foundation Europe e.V.
3+
#
4+
# SPDX-License-Identifier: CC0-1.0
5+
# SPDX-License-Identifier: MIT
6+
name: REUSE Compliance Check
7+
8+
on: [push, pull_request]
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v6.0.2
15+
- name: REUSE Compliance Check
16+
uses: fsfe/reuse-action@v6
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# SPDX-FileCopyrightText: 2026 OpenCHAMI Contributors
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
name: Codegen Check
6+
7+
on:
8+
pull_request:
9+
branches: [main]
10+
paths:
11+
- "apis/**"
12+
- "cmd/server/**"
13+
- "internal/middleware/**"
14+
- "internal/storage/**"
15+
- "pkg/apiversion/**"
16+
- "pkg/client/**"
17+
- "pkg/reconcilers/**"
18+
- "Makefile"
19+
- ".github/workflows/codegen-check.yaml"
20+
workflow_dispatch:
21+
22+
jobs:
23+
codegen-drift:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v6.0.2
28+
29+
- name: Set up Go
30+
uses: actions/setup-go@v6.4.0
31+
with:
32+
go-version: stable
33+
34+
- name: Verify generated code is committed
35+
run: make generate-check
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright © 2026 OpenCHAMI a Series of LF Projects, LLC
2+
#
3+
# SPDX-License-Identifier: MIT
4+
name: golangci-lint
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
workflow_dispatch:
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Set up latest stable Go
18+
uses: actions/setup-go@v6.4.0
19+
with:
20+
go-version: stable
21+
- uses: actions/checkout@v6.0.2
22+
- name: Run golangci-lint
23+
uses: golangci/golangci-lint-action@v9.2.0
24+
with:
25+
version: latest

.github/workflows/release.yaml

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,83 @@
1-
# SPDX-FileCopyrightText: 2026 Copyright © 2026 OpenCHAMI a Series of LF Projects, LLC
1+
# Copyright © 2026 OpenCHAMI a Series of LF Projects, LLC
22
#
33
# SPDX-License-Identifier: MIT
44

5-
name: Release
5+
name: Release with goreleaser
66

77
on:
8+
workflow_dispatch:
89
push:
910
tags:
10-
- 'v*.*.*'
11+
- v*
1112

12-
permissions:
13-
contents: write
14-
packages: write
13+
permissions: write-all # Necessary for the generate-build-provenance action with containers
1514

1615
jobs:
17-
goreleaser:
16+
17+
build:
18+
19+
1820
runs-on: ubuntu-latest
19-
steps:
20-
- name: Checkout
21-
uses: actions/checkout@v4
22-
with:
23-
fetch-depth: 0
2421

25-
- name: Set up Go
26-
uses: actions/setup-go@v5
22+
steps:
23+
- name: Set up latest stable Go
24+
uses: actions/setup-go@v6.4.0
2725
with:
28-
go-version: '1.23'
29-
26+
go-version: stable
3027
- name: Set up QEMU
3128
uses: docker/setup-qemu-action@v3
32-
3329
- name: Set up Docker Buildx
3430
uses: docker/setup-buildx-action@v3
35-
36-
- name: Login to GitHub Container Registry
31+
with:
32+
driver-opts: |
33+
image=moby/buildkit:master
34+
network=host
35+
- name: Docker Login
3736
uses: docker/login-action@v3
3837
with:
3938
registry: ghcr.io
4039
username: ${{ github.actor }}
4140
password: ${{ secrets.GITHUB_TOKEN }}
41+
- name: Checkout
42+
uses: actions/checkout@v6.0.2
43+
with:
44+
fetch-tags: 1
45+
fetch-depth: 0
46+
# Set environment variables required by GoReleaser
47+
- name: Set build environment variables
48+
run: |
49+
echo "GIT_STATE=$(if git diff-index --quiet HEAD --; then echo 'clean'; else echo 'dirty'; fi)" >> $GITHUB_ENV
50+
echo "BUILD_HOST=$(hostname)" >> $GITHUB_ENV
51+
echo "GO_VERSION=$(go version | awk '{print $3}')" >> $GITHUB_ENV
52+
echo "BUILD_USER=$(whoami)" >> $GITHUB_ENV
53+
echo "CGO_ENABLED=0" >> $GITHUB_ENV
54+
echo "IS_PR_BUILD=false" >> $GITHUB_ENV
4255
43-
- name: Run GoReleaser
56+
- name: Release with goreleaser
4457
uses: goreleaser/goreleaser-action@v6
58+
env:
59+
GITHUB_TOKEN: ${{ github.token }}
4560
with:
46-
distribution: goreleaser
47-
version: '~> v2'
61+
version: latest
4862
args: release --clean
49-
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
id: goreleaser
64+
- name: Process goreleaser output
65+
id: process_goreleaser_output
66+
run: |
67+
echo "const fs = require('fs');" > process.js
68+
echo 'const artifacts = ${{ steps.goreleaser.outputs.artifacts }}' >> process.js
69+
echo "const firstNonNullDigest = artifacts.find(artifact => artifact.extra && artifact.extra.Digest != null)?.extra.Digest;" >> process.js
70+
echo "console.log(firstNonNullDigest);" >> process.js
71+
echo "fs.writeFileSync('digest.txt', firstNonNullDigest);" >> process.js
72+
node process.js
73+
echo "digest=$(cat digest.txt)" >> $GITHUB_OUTPUT
74+
- name: Attest Binaries
75+
uses: actions/attest-build-provenance@v1
76+
with:
77+
subject-path: dist/**/fru-tracker*
78+
- name: generate build provenance
79+
uses: actions/attest-build-provenance@v1
80+
with:
81+
subject-name: ghcr.io/openchami/fru-tracker
82+
subject-digest: ${{ steps.process_goreleaser_output.outputs.digest }}
83+
push-to-registry: true

0 commit comments

Comments
 (0)