-
Notifications
You must be signed in to change notification settings - Fork 0
203 lines (173 loc) · 5.82 KB
/
Copy pathci.yml
File metadata and controls
203 lines (173 loc) · 5.82 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
name: CI/CD Pipeline
on:
push:
branches: [ master, main ]
tags:
- 'v*'
pull_request:
branches: [ master, main ]
env:
REGISTRY: gcr.io
IMAGE_NAME: ${{ secrets.GCR_PROJECT_ID }}/redvector
jobs:
fmt:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
test:
name: Test Suite
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, nightly]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@${{ matrix.rust }}
- name: Cache Cargo dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.rust }}-
- name: Run tests
run: cargo test --all --verbose
build:
name: Build Release
runs-on: ubuntu-latest
needs: [fmt, test]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-stable-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-stable-
- name: Build release binary
run: cargo build --release --verbose
- name: Upload release artifacts
uses: actions/upload-artifact@v3
with:
name: redvector-binary
path: target/release/redvector
retention-days: 30
docker-build:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [fmt, test]
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
service_account_key: ${{ secrets.GCR_SA_KEY }}
project_id: ${{ secrets.GCR_PROJECT_ID }}
- name: Configure Docker for GCR
run: gcloud auth configure-docker ${{ env.REGISTRY }} --quiet
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image (Debian)
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
- name: Build and push Docker image (Distroless)
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.distroless
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:distroless-${{ steps.meta.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
release:
name: Create Release
runs-on: ubuntu-latest
needs: [build, docker-build]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download release artifacts
uses: actions/download-artifact@v3
with:
name: redvector-binary
path: ./artifacts
- name: Get version from tag
id: tag
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Generate changelog
id: changelog
run: |
CHANGELOG=$(git log --pretty=format:"- %s (%h)" $(git describe --tags --abbrev=0 HEAD^)..HEAD)
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/redvector
name: Release v${{ steps.tag.outputs.VERSION }}
body: |
## Release v${{ steps.tag.outputs.VERSION }}
### Changes
${{ steps.changelog.outputs.CHANGELOG }}
### Docker Images
- `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.tag.outputs.VERSION }}`
- `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest`
- `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:distroless-v${{ steps.tag.outputs.VERSION }}`
### Installation
```bash
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.tag.outputs.VERSION }}
```
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}