Skip to content

Commit 21c097d

Browse files
authored
Merge pull request #4 from linuxfoundation/jme/LFXV2-54
feature: add ko build workflow
2 parents 13a7d52 + 03428ca commit 21c097d

File tree

5 files changed

+167
-6
lines changed

5 files changed

+167
-6
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright The Linux Foundation and each contributor to LFX.
2+
# SPDX-License-Identifier: MIT
3+
---
4+
name: Publish Main
5+
6+
'on':
7+
push:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
publish:
17+
name: Publish Main
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-go@v5
25+
with:
26+
go-version-file: go.mod
27+
- uses: ko-build/setup-ko@v0.8
28+
with:
29+
version: v0.17.1
30+
- run: |
31+
ko build github.com/linuxfoundation/lfx-v2-query-service/cmd \
32+
-B \
33+
--platform linux/amd64,linux/arm64 \
34+
-t ${{ github.sha }} \
35+
-t development \
36+
--sbom spdx
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Copyright The Linux Foundation and each contributor to LFX.
2+
# SPDX-License-Identifier: MIT
3+
---
4+
name: Publish Tagged Release
5+
6+
on:
7+
push:
8+
tags:
9+
- v*
10+
11+
env:
12+
COSIGN_VERSION: v2.5.3
13+
HELM_VERSION: v3.18.4
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
publish:
20+
name: Publish Tagged Release
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
outputs:
26+
app_version: ${{ steps.prepare.outputs.app_version }}
27+
chart_name: ${{ steps.prepare.outputs.chart_name }}
28+
chart_version: ${{ steps.prepare.outputs.chart_version }}
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
32+
33+
- name: Prepare versions and chart name
34+
id: prepare
35+
run: |
36+
set -euo pipefail
37+
APP_VERSION=$(echo ${{ github.ref_name }} | sed 's/v//g')
38+
CHART_NAME="$(yq '.name' charts/*/Chart.yaml)"
39+
CHART_VERSION="$(yq '.version' charts/*/Chart.yaml)"
40+
{
41+
echo "app_version=$APP_VERSION"
42+
echo "chart_name=$CHART_NAME"
43+
echo "chart_version=$CHART_VERSION"
44+
} >> "$GITHUB_OUTPUT"
45+
46+
- name: Setup Go
47+
uses: actions/setup-go@v5
48+
with:
49+
go-version-file: go.mod
50+
51+
- name: Setup Ko
52+
uses: ko-build/setup-ko@v0.8
53+
with:
54+
version: v0.17.1
55+
56+
- name: Build and publish query service image
57+
run: |
58+
ko build github.com/linuxfoundation/lfx-v2-query-service/cmd \
59+
-B \
60+
--platform linux/amd64,linux/arm64 \
61+
-t ${{ github.ref_name }} \
62+
-t ${{ steps.prepare.outputs.app_version }} \
63+
-t latest \
64+
--sbom spdx
65+
66+
release-helm-chart:
67+
needs: publish
68+
runs-on: ubuntu-24.04
69+
permissions:
70+
contents: write
71+
packages: write
72+
id-token: write
73+
outputs:
74+
digest: ${{ steps.publish-ghcr.outputs.digest }}
75+
image_name: ${{ steps.publish-ghcr.outputs.image_name }}
76+
steps:
77+
- name: Checkout repository
78+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
79+
80+
- name: Publish Chart to GHCR
81+
id: publish-ghcr
82+
uses: linuxfoundation/lfx-public-workflows/.github/actions/helm-chart-oci-publisher@c465d6571fa0b8be9d551d902955164ea04a00af # main
83+
with:
84+
name: ${{ needs.publish.outputs.chart_name }}
85+
repository: ${{ github.repository }}/chart
86+
chart_version: ${{ needs.publish.outputs.chart_version }}
87+
app_version: ${{ needs.publish.outputs.app_version }}
88+
registry: ghcr.io
89+
registry_username: ${{ github.actor }}
90+
registry_password: ${{ secrets.GITHUB_TOKEN }}
91+
92+
- name: Install Cosign
93+
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
94+
with:
95+
cosign-release: "${{ env.COSIGN_VERSION }}"
96+
97+
- name: Login to GitHub
98+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
99+
with:
100+
registry: ghcr.io
101+
username: ${{ github.actor }}
102+
password: ${{ secrets.GITHUB_TOKEN }}
103+
104+
- name: Sign the Helm chart in GHCR
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
run: |
108+
set -euo pipefail
109+
cosign sign --yes '${{ steps.publish-ghcr.outputs.image_name }}@${{ steps.publish-ghcr.outputs.digest }}'
110+
111+
create-ghcr-helm-provenance:
112+
needs:
113+
- release-helm-chart
114+
permissions:
115+
actions: read
116+
id-token: write
117+
packages: write
118+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.1.0
119+
with:
120+
image: ${{ needs.release-helm-chart.outputs.image_name }}
121+
digest: ${{ needs.release-helm-chart.outputs.digest }}
122+
registry-username: ${{ github.actor }}
123+
secrets:
124+
registry-password: ${{ secrets.GITHUB_TOKEN }}

charts/lfx-v2-query-service/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ name: lfx-v2-query-service
66
description: LFX Platform V2 Query Service chart
77
type: application
88
version: 0.1.0
9-
appVersion: "0.1.0"
9+
appVersion: "latest"

charts/lfx-v2-query-service/templates/deployment.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ metadata:
77
name: query-svc
88
namespace: lfx
99
spec:
10-
replicas: {{ .Values.replicaCount }}
10+
replicas: {{ .Values.replicaCount }}
1111
selector:
1212
matchLabels:
1313
app: query-svc
@@ -18,8 +18,8 @@ spec:
1818
spec:
1919
containers:
2020
- name: app
21-
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
22-
imagePullPolicy: Never
21+
image: {{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}
22+
imagePullPolicy: {{ .Values.image.pullPolicy }}
2323
env:
2424
- name: OPENSEARCH_URL
2525
value: {{.Values.opensearch.url}}

charts/lfx-v2-query-service/values.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ replicaCount: 1
55

66
# Override from CLI/CI: --set image.tag=<git-sha>, etc.
77
image:
8-
tag: "0.1.0"
9-
repository: linuxfoundation/lfx-query-svc
8+
repository: ghcr.io/linuxfoundation/lfx-v2-query-service/cmd
9+
tag: ""
10+
pullPolicy: IfNotPresent
1011

1112
# ingress is the configuration for the ingress routing
1213
ingress:

0 commit comments

Comments
 (0)