-
Notifications
You must be signed in to change notification settings - Fork 1
118 lines (100 loc) · 3.62 KB
/
Copy pathrelease.yaml
File metadata and controls
118 lines (100 loc) · 3.62 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
name: Release
on:
push:
tags:
- '*.*.*'
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
env:
DOCKERHUB_TEAM_NAME: drdroidlab
IMAGE_NAME: drd-vpc-agent
GHCR_REGISTRY: ghcr.io
GHCR_IMAGE: ghcr.io/drdroidlab/drd-vpc-agent/drd-vpc-agent
HELM_CHART_PATH: helm
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: |
# Remove 'v' prefix from tag to get semver
VERSION=${GITHUB_REF_NAME#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$GITHUB_REF_NAME" >> $GITHUB_OUTPUT
echo "Releasing version: $VERSION"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_TEAM_NAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKERHUB_TEAM_NAME }}/${{ env.IMAGE_NAME }}
${{ env.GHCR_IMAGE }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
COMMIT_HASH=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.14.0
- name: Update Helm chart versions
run: |
VERSION="${{ steps.version.outputs.version }}"
CHART_PATH="${{ env.HELM_CHART_PATH }}"
# Update all version fields in all Chart.yaml files to the release version
# This handles both chart versions and dependency versions
find ${CHART_PATH} -name "Chart.yaml" -exec sed -i "s/\(version:\s*\)[0-9][0-9.]*/\1${VERSION}/g" {} \;
# Update appVersion in parent Chart.yaml
sed -i "s/^appVersion:.*/appVersion: \"${VERSION}\"/" ${CHART_PATH}/Chart.yaml
# Display updated Chart files
echo "=== Parent Chart.yaml ==="
cat ${CHART_PATH}/Chart.yaml
echo ""
echo "=== redis/Chart.yaml ==="
cat ${CHART_PATH}/charts/redis/Chart.yaml
echo ""
echo "=== celery_beat/Chart.yaml ==="
cat ${CHART_PATH}/charts/celery_beat/Chart.yaml
echo ""
echo "=== celery_worker/Chart.yaml ==="
cat ${CHART_PATH}/charts/celery_worker/Chart.yaml
- name: Package Helm chart
run: |
helm dependency update ${{ env.HELM_CHART_PATH }}
helm package ${{ env.HELM_CHART_PATH }} --destination .helm-packages
- name: Push Helm chart to GHCR
run: |
helm push .helm-packages/${{ env.IMAGE_NAME }}-${{ steps.version.outputs.version }}.tgz oci://${{ env.GHCR_REGISTRY }}/drdroidlab/charts