-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (126 loc) · 4.29 KB
/
deploy.yml
File metadata and controls
144 lines (126 loc) · 4.29 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
name: Release & Push
on:
workflow_dispatch:
inputs:
bump_type:
description: "Version bump type"
required: true
default: "patch"
type: choice
options:
- major
- minor
- patch
concurrency:
group: gps-release-deploy
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
new_tag: ${{ steps.bump.outputs.new_tag }}
changelog: ${{ steps.changelog.outputs.changelog }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Get latest tag
id: latest
run: |
tag=$(git tag -l 'v*.*.*' --sort=-v:refname | head -1)
echo "tag=${tag:-v0.0.0}" >> "$GITHUB_OUTPUT"
- name: Calculate next version
id: bump
env:
BUMP_TYPE: ${{ inputs.bump_type }}
LATEST_TAG: ${{ steps.latest.outputs.tag }}
run: |
version="${LATEST_TAG#v}"
IFS='.' read -r major minor patch <<< "$version"
case "$BUMP_TYPE" in
major) major=$((major + 1)); minor=0; patch=0 ;;
minor) minor=$((minor + 1)); patch=0 ;;
patch) patch=$((patch + 1)) ;;
esac
new_tag="v${major}.${minor}.${patch}"
echo "new_tag=$new_tag" >> "$GITHUB_OUTPUT"
echo "## Version bump: $LATEST_TAG -> $new_tag" >> "$GITHUB_STEP_SUMMARY"
- name: Generate changelog
id: changelog
env:
LATEST_TAG: ${{ steps.latest.outputs.tag }}
run: |
if git rev-parse "$LATEST_TAG" >/dev/null 2>&1; then
log=$(git log "${LATEST_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges)
else
log=$(git log --pretty=format:"- %s (%h)" --no-merges)
fi
{
echo "changelog<<EOF"
echo "$log"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- uses: rickstaa/action-create-tag@v1
with:
tag: ${{ steps.bump.outputs.new_tag }}
message: "Release ${{ steps.bump.outputs.new_tag }}"
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.bump.outputs.new_tag }}
name: ${{ steps.bump.outputs.new_tag }}
body: |
## Changes
${{ steps.changelog.outputs.changelog }}
generate_release_notes: false
build:
needs: release
runs-on: ${{ matrix.arch.runner }}
strategy:
matrix:
arch:
- { runner: ubuntu-latest, platform: linux/amd64, suffix: amd64 }
- { runner: ubuntu-24.04-arm, platform: linux/arm64, suffix: arm64 }
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.release.outputs.new_tag }}
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- uses: astral-sh/setup-uv@v7
- name: Build GPS database
run: uv run scripts/build_db.py --force
- uses: docker/build-push-action@v7
with:
context: .
file: Containerfile
push: true
platforms: ${{ matrix.arch.platform }}
tags: quay.io/ambient_code/gps:${{ needs.release.outputs.new_tag }}-${{ matrix.arch.suffix }}
cache-from: type=gha,scope=build-${{ matrix.arch.suffix }}
cache-to: type=gha,mode=max,scope=build-${{ matrix.arch.suffix }}
merge-manifests:
needs: [release, build]
runs-on: ubuntu-latest
steps:
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Create multi-arch manifest
env:
TAG: ${{ needs.release.outputs.new_tag }}
run: |
docker buildx imagetools create -t "quay.io/ambient_code/gps:${TAG}" \
"quay.io/ambient_code/gps:${TAG}-amd64" \
"quay.io/ambient_code/gps:${TAG}-arm64"
docker buildx imagetools create -t "quay.io/ambient_code/gps:latest" \
"quay.io/ambient_code/gps:${TAG}-amd64" \
"quay.io/ambient_code/gps:${TAG}-arm64"