-
Notifications
You must be signed in to change notification settings - Fork 48
92 lines (80 loc) · 3.05 KB
/
push-artifacts.yaml
File metadata and controls
92 lines (80 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# /*
# Copyright 2025 The Grove Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# */
name: Build and Publish Artifacts
on:
push:
branches:
- "main"
workflow_call:
inputs:
version:
description: 'Package version to use (e.g., v1.0.0)'
required: false
type: string
permissions:
contents: read
packages: write
jobs:
build-and-push:
name: Build & Push
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set package version
run: |
if [ -n "${{ inputs.version }}" ]; then
# Use version provided by workflow_call
PACKAGE_VERSION="${{ inputs.version }}"
else
# Extract from commit hash for main branch pushes
# We add a 'g' prefix to the hash.
# This prevents "all-number" hashes starting with 0 from breaking Helm (invalid semver)
PACKAGE_VERSION=v0.0.0-g$(git rev-parse --short HEAD)
fi
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
echo $PACKAGE_VERSION
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.7'
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set Docker Registry
run: |
DOCKER_REGISTRY=$(echo 'ghcr.io/${{ github.repository }}' | tr '[:upper:]' '[:lower:]')
echo "DOCKER_REGISTRY=$DOCKER_REGISTRY" >> $GITHUB_ENV
- name: Docker build & push
run: |
make --directory=operator docker-build PLATFORM=linux/amd64,linux/arm64 VERSION=$PACKAGE_VERSION REGISTRY=$DOCKER_REGISTRY DOCKER_BUILD_ADDITIONAL_ARGS=--push
- name: Copy CRDs to charts
run: |
./operator/hack/prepare-charts.sh
- name: Build Helm chart
run: |
sed -i "s#repository: grove-operator#repository: $DOCKER_REGISTRY/grove-operator#" operator/charts/values.yaml
sed -i "s#tag:.*#tag: $PACKAGE_VERSION#" operator/charts/values.yaml
sed -i "s#value: grove-initc#value: $DOCKER_REGISTRY/grove-initc#" operator/charts/values.yaml
helm package ./operator/charts --app-version $PACKAGE_VERSION --version $PACKAGE_VERSION
- name: Push Helm Chart
run: |
helm push ./grove-charts-$PACKAGE_VERSION.tgz oci://$DOCKER_REGISTRY