forked from Saremox/redis-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (108 loc) · 3.78 KB
/
Copy pathrelease.yml
File metadata and controls
130 lines (108 loc) · 3.78 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Release
on:
push:
tags:
# Tags without leading 'v' (e.g., 4.0.0, not v4.0.0)
- '[0-9]*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- 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 Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Image tags WITHOUT leading 'v' (git tag v4.0.0 -> image tag 4.0.0)
# Chart version and image tag are the same (4.0.0)
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/app/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Generate deployment manifests
run: |
mkdir -p release-artifacts
# Generate kustomize manifests with the new image
cd manifests/kustomize/base
kustomize edit set image redis-operator=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
cd ../../..
# Build the full manifest
kustomize build manifests/kustomize/base > release-artifacts/redis-operator.yaml
# Also include raw manifests
cp -r manifests/*.yaml release-artifacts/ 2>/dev/null || true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
release-artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
helm-release:
runs-on: ubuntu-latest
needs: build-and-push
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: v3.14.0
- name: Update Chart version and image
run: |
# Git tag is the version directly (4.0.0, no 'v' prefix)
VERSION="${GITHUB_REF_NAME}"
# Update Chart.yaml - version, appVersion all match tag
sed -i "s/^version:.*/version: $VERSION/" charts/redisoperator/Chart.yaml
sed -i "s/^appVersion:.*/appVersion: \"$VERSION\"/" charts/redisoperator/Chart.yaml
# Update values.yaml with new image
sed -i "s|repository:.*|repository: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}|" charts/redisoperator/values.yaml
sed -i "s/tag:.*/tag: \"$VERSION\"/" charts/redisoperator/values.yaml
- name: Release Helm Chart
uses: helm/chart-releaser-action@v1.7.0
with:
charts_dir: charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"