-
Notifications
You must be signed in to change notification settings - Fork 2
139 lines (123 loc) · 4.26 KB
/
release.yaml
File metadata and controls
139 lines (123 loc) · 4.26 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
131
132
133
134
135
136
137
138
139
name: Release & Build Images
on:
push:
branches: [main]
paths:
- "src/bender/__init__.py"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
release:
name: Create release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.version }}
created: ${{ steps.check.outputs.created }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version from __init__.py
id: extract
run: |
VERSION=$(python -c "import re; print(re.search(r'__version__\s*=\s*\"(.+?)\"', open('src/bender/__init__.py').read()).group(1))")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Extracted version: $VERSION"
- name: Check if tag already exists
id: check
run: |
VERSION="${{ steps.extract.outputs.version }}"
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "Tag v$VERSION already exists, skipping"
echo "created=false" >> "$GITHUB_OUTPUT"
else
echo "Tag v$VERSION does not exist, creating release"
echo "created=true" >> "$GITHUB_OUTPUT"
fi
- name: Update Helm chart version
if: steps.check.outputs.created == 'true'
run: |
VERSION="${{ steps.extract.outputs.version }}"
sed -i "s/^version: .*/version: $VERSION/" helm/Chart.yaml
sed -i "s/^appVersion: .*/appVersion: \"$VERSION\"/" helm/Chart.yaml
sed -i "s/^ tag: .*/ tag: \"infra-$VERSION\"/" helm/values.yaml
- name: Commit Helm chart updates
if: steps.check.outputs.created == 'true'
run: |
VERSION="${{ steps.extract.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add helm/Chart.yaml helm/values.yaml
git commit -m "Update Helm chart to v$VERSION"
git push origin main
- name: Create tag and GitHub release
if: steps.check.outputs.created == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.extract.outputs.version }}"
git tag "v$VERSION"
git push origin "v$VERSION"
gh release create "v$VERSION" --generate-notes --title "v$VERSION"
build-base:
name: Build base image
runs-on: ubuntu-latest
needs: release
if: needs.release.outputs.created == 'true'
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push base image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.version }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
build-infra:
name: Build infra image
runs-on: ubuntu-latest
needs: release
if: needs.release.outputs.created == 'true'
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push infra image
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:infra-${{ needs.release.outputs.version }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:infra-latest