-
Notifications
You must be signed in to change notification settings - Fork 3
252 lines (213 loc) · 8.34 KB
/
Copy pathversion-bump.yml
File metadata and controls
252 lines (213 loc) · 8.34 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
name: Version Bump
on:
push:
branches:
- main
concurrency:
group: version-bump
cancel-in-progress: false
jobs:
# Phase 1: Create version bump PR (runs for non-version-bump commits)
bump-version:
runs-on: ubuntu-latest
if: "!startsWith(github.event.head_commit.message, 'chore: bump version to')"
steps:
- name: Generate GeoSetBot token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Get PR info
id: pr
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
PR_JSON=$(gh pr list --search "${{ github.sha }}" --state merged --json title,number --jq '.[0]')
PR_TITLE=$(echo "$PR_JSON" | jq -r '.title // empty')
PR_NUMBER=$(echo "$PR_JSON" | jq -r '.number // empty')
if [ -z "$PR_TITLE" ]; then
PR_TITLE=$(git log -1 --pretty=%s)
fi
echo "title=$PR_TITLE" >> "$GITHUB_OUTPUT"
echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
- name: Bump version and update changelog
id: version
run: |
OUTPUT=$(./scripts/bump_version.sh \
--pr-title "${{ steps.pr.outputs.title }}" \
--pr-number "${{ steps.pr.outputs.number }}" \
--repo "${{ github.repository }}")
echo "$OUTPUT"
echo "new_version=$(echo "$OUTPUT" | grep '^NEW_VERSION=' | cut -d= -f2)" >> "$GITHUB_OUTPUT"
- name: Create or update Pull Request
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
git config user.name "geoset-bot[bot]"
git config user.email "geoset-bot[bot]@users.noreply.github.com"
# Check for an existing open version bump PR
EXISTING_PR=$(gh pr list --search "chore: bump version to" --state open \
--json number,headRefName --jq '.[0]')
EXISTING_BRANCH=$(echo "$EXISTING_PR" | jq -r '.headRefName // empty')
if [[ -n "$EXISTING_BRANCH" ]]; then
# Append changelog entry to the existing bump branch
git fetch origin "$EXISTING_BRANCH"
git checkout "$EXISTING_BRANCH"
# Re-run the bump script on top of the existing branch
./scripts/bump_version.sh \
--pr-title "${{ steps.pr.outputs.title }}" \
--pr-number "${{ steps.pr.outputs.number }}" \
--repo "${{ github.repository }}"
git add VERSIONING.md
git commit -m "chore: add changelog entry for #${{ steps.pr.outputs.number }}"
git push origin "$EXISTING_BRANCH"
# Update the PR title to reflect the latest version
NEW_VERSION=$(sed -n 's/.*\*\*Current Version:\*\* \([^ ]*\).*/\1/p' VERSIONING.md)
gh pr edit "$EXISTING_BRANCH" \
--title "chore: bump version to $NEW_VERSION"
else
# Create a new bump PR
BRANCH="chore/version-bump-${{ steps.version.outputs.new_version }}"
# Delete stale remote branch from a previous failed run, if it exists
git push origin --delete "$BRANCH" 2>/dev/null || true
git checkout -b "$BRANCH"
git add VERSIONING.md
git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }}"
git push origin "$BRANCH"
gh pr create \
--title "chore: bump version to ${{ steps.version.outputs.new_version }}" \
--body "Automated version bump and changelog update." \
--base main \
--head "$BRANCH"
fi
# Phase 2: Tag and build Docker (runs when a version bump PR is merged)
create-tag:
runs-on: ubuntu-latest
if: "startsWith(github.event.head_commit.message, 'chore: bump version to')"
outputs:
new_version: ${{ steps.version.outputs.new_version }}
steps:
- name: Generate GeoSetBot token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Extract version
id: version
run: |
NEW_VERSION=$(grep -oP '(?<=\*\*Current Version:\*\* )\S+' VERSIONING.md)
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
- name: Create tag
run: |
git config user.name "geoset-bot[bot]"
git config user.email "geoset-bot[bot]@users.noreply.github.com"
git tag "v${{ steps.version.outputs.new_version }}"
git push origin "v${{ steps.version.outputs.new_version }}"
docker-debian:
runs-on: ubuntu-latest
needs: create-tag
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: main
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build and Push
uses: docker/build-push-action@v6
with:
context: .
target: lean
platforms: linux/amd64,linux/arm64
push: true
tags: ebienstock/geoset:${{ needs.create-tag.outputs.new_version }}
build-args: BUILD_VERSION=${{ needs.create-tag.outputs.new_version }}
cache-from: type=gha,scope=debian
cache-to: type=gha,mode=max,scope=debian
- name: Tag as latest
run: |
docker buildx imagetools create \
ebienstock/geoset:${{ needs.create-tag.outputs.new_version }} \
--tag ebienstock/geoset:latest
docker-rhel:
runs-on: ubuntu-latest
needs: create-tag
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: main
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build and Push RHEL
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.rhel
target: production
platforms: linux/amd64,linux/arm64
push: true
tags: ebienstock/geoset:${{ needs.create-tag.outputs.new_version }}-rhel
build-args: BUILD_VERSION=${{ needs.create-tag.outputs.new_version }}
cache-from: type=gha,scope=rhel
cache-to: type=gha,mode=max,scope=rhel
- name: Tag as latest
run: |
docker buildx imagetools create \
ebienstock/geoset:${{ needs.create-tag.outputs.new_version }}-rhel \
--tag ebienstock/geoset:latest-rhel
docker-ingest:
runs-on: ubuntu-latest
needs: create-tag
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: main
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build and Push Data Ingest
uses: docker/build-push-action@v6
with:
context: ./sample-data
platforms: linux/amd64,linux/arm64
push: true
tags: ebienstock/geoset:data-ingest-${{ needs.create-tag.outputs.new_version }}
cache-from: type=gha,scope=data-ingest
cache-to: type=gha,mode=max,scope=data-ingest
- name: Tag as latest
run: |
docker buildx imagetools create \
ebienstock/geoset:data-ingest-${{ needs.create-tag.outputs.new_version }} \
--tag ebienstock/geoset:data-ingest-latest