Skip to content

Commit 65e76d8

Browse files
Merge pull request #110 from CodeLieutenant/feat/release
feature(ci): add github actions for testing and releasing
2 parents da2967f + 6c85a6a commit 65e76d8

File tree

14 files changed

+498
-73
lines changed

14 files changed

+498
-73
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cassandra-download/
2+
target/
3+
.github/

.github/dependabot.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: /
6+
schedule:
7+
interval: "monthly"
8+
9+
- package-ecosystem: "cargo"
10+
directory: "/"
11+
schedule:
12+
interval: "weekly"
13+
rebase-strategy: "disabled"

.github/workflows/docker.yml

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Docker Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
default: "dev"
8+
required: false
9+
type: string
10+
secrets:
11+
DOCKERHUB_TOKEN:
12+
required: true
13+
DOCKERHUB_USERNAME:
14+
required: true
15+
16+
workflow_dispatch:
17+
inputs:
18+
version:
19+
default: ""
20+
required: true
21+
type: string
22+
23+
jobs:
24+
build-image:
25+
name: Build ${{ matrix.build.platform }}
26+
runs-on: ubuntu-24.04${{ matrix.build.platform == 'linux/arm64/v8' && '-arm' || '' }}
27+
strategy:
28+
matrix:
29+
build:
30+
- platform: linux/amd64
31+
arch_short: amd
32+
- platform: linux/arm64/v8
33+
arch_short: arm
34+
steps:
35+
- name: Checkout Repository
36+
uses: actions/checkout@v4
37+
with:
38+
fetch-depth: 0
39+
40+
- name: Log in to DockerHub
41+
uses: docker/login-action@v3
42+
with:
43+
username: ${{ secrets.DOCKERHUB_USERNAME }}
44+
password: ${{ secrets.DOCKERHUB_TOKEN }}
45+
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
49+
- name: Enable BuildKit
50+
run: echo "DOCKER_BUILDKIT=1" >> $GITHUB_ENV
51+
52+
- name: Build and Cache Image for the ${{ matrix.build.platform }} platform
53+
run: |
54+
docker buildx build \
55+
-t scylladb/cql-stress \
56+
--platform ${{ matrix.build.platform }} \
57+
--provenance false \
58+
--metadata-file metadata \
59+
--output push-by-digest=true,type=image,push=true \
60+
.
61+
echo "Metadata file info:"
62+
cat metadata
63+
CURRENT_SHA=$(grep -oP '"containerimage.digest": *"\Ksha256:[a-f0-9]+' metadata)
64+
echo CURRENT_SHA=$CURRENT_SHA
65+
echo $CURRENT_SHA > digest-${{ matrix.build.arch_short }}
66+
67+
- name: Upload Digest Artifact
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: digest-${{ matrix.build.arch_short }}
71+
path: digest-${{ matrix.build.arch_short }}
72+
73+
push-images:
74+
name: Push Multiarch Images
75+
needs: build-image
76+
runs-on: ubuntu-24.04
77+
steps:
78+
- name: Checkout
79+
uses: actions/checkout@v4
80+
with:
81+
fetch-depth: 0
82+
83+
- name: Log in to DockerHub
84+
uses: docker/login-action@v3
85+
with:
86+
username: ${{ secrets.DOCKERHUB_USERNAME }}
87+
password: ${{ secrets.DOCKERHUB_TOKEN }}
88+
89+
- name: Set up Docker Buildx
90+
uses: docker/setup-buildx-action@v3
91+
92+
- name: Enable BuildKit
93+
run: echo "DOCKER_BUILDKIT=1" >> $GITHUB_ENV
94+
95+
- name: Download Digests
96+
uses: actions/download-artifact@v4
97+
with:
98+
path: digests
99+
100+
- name: Create Multi-Arch Manifest and Push
101+
run: |
102+
ls -Rl digests
103+
SHA_AMD=$(cat digests/digest-amd/digest-amd)
104+
SHA_ARM=$(cat digests/digest-arm/digest-arm)
105+
echo SHA_AMD=$SHA_AMD
106+
echo SHA_ARM=$SHA_ARM
107+
docker manifest create scylladb/cql-stress:${{ inputs.version }} \
108+
--amend scylladb/cql-stress@$SHA_AMD \
109+
--amend scylladb/cql-stress@$SHA_ARM
110+
docker manifest push scylladb/cql-stress:${{ inputs.version }}
111+
docker manifest inspect scylladb/cql-stress:${{ inputs.version }}
112+
113+
docker manifest create scylladb/cql-stress:latest \
114+
--amend scylladb/cql-stress@$SHA_AMD \
115+
--amend scylladb/cql-stress@$SHA_ARM
116+
docker manifest push scylladb/cql-stress:latest
117+
docker manifest inspect scylladb/cql-stress:latest
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Update Docker Hub Description
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- README.md
9+
- .github/workflows/dockerhub-description.yml
10+
11+
jobs:
12+
description:
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Docker Hub Description
17+
uses: peter-evans/dockerhub-description@v4
18+
with:
19+
username: ${{ secrets.DOCKERHUB_USERNAME }}
20+
password: ${{ secrets.DOCKERHUB_TOKEN }}
21+
repository: scylladb/cql-stress
22+
short-description: ${{ github.event.repository.description }}
23+
enable-url-completion: true

.github/workflows/release.yml

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: "Release"
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
env:
9+
RUSTFLAGS: "--cfg fetch_extended_version_info"
10+
CARGO_TERM_COLOR: always
11+
PYTHONUNBUFFERED: "1"
12+
13+
jobs:
14+
get_tag:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
tag: ${{ steps.version_tag.outputs.tag }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 1
22+
- name: Get Tag
23+
uses: olegtarasov/[email protected]
24+
id: version_tag
25+
with:
26+
tagRegex: "(.*)"
27+
28+
release:
29+
runs-on: ubuntu-24.04
30+
steps:
31+
- name: Create release
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
tag: ${{ github.ref_name }}
35+
run: |
36+
set +e
37+
if [[ "$(gh release view $tag 2>&1)" == "release not found" ]]; then
38+
echo "Release '$tag' not found. Creating..."
39+
gh release create "$tag" \
40+
--repo="$GITHUB_REPOSITORY" \
41+
--title="${GITHUB_REPOSITORY#*/} ${tag#}" \
42+
--generate-notes
43+
else
44+
echo "Release '$tag' found. Skipping this step..."
45+
fi
46+
47+
docker_build:
48+
uses: ./.github/workflows/docker.yml
49+
needs: [get_tag]
50+
with:
51+
version: ${{ needs.get_tag.outputs.tag }}
52+
secrets:
53+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
54+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
55+
56+
release-artifacts:
57+
needs: [get_tag]
58+
strategy:
59+
matrix:
60+
os: [ubuntu-22.04, ubuntu-24.04, ubuntu-24.04-arm]
61+
runs-on: ${{ matrix.os }}
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v4
65+
- uses: actions-rust-lang/setup-rust-toolchain@v1
66+
67+
- name: Build CQLStressScyllaBench Binary
68+
uses: actions-rs/cargo@v1
69+
with:
70+
command: build
71+
args: --profile dist --all
72+
73+
- name: Set Binary Name
74+
run: |
75+
BIN_NAME_CS="cql-stress-cassandra-stress-${{ needs.get_tag.outputs.tag }}-${{ matrix.os }}"
76+
BIN_NAME_SB="cql-stress-scylla-bench-${{ needs.get_tag.outputs.tag }}-${{ matrix.os }}"
77+
echo "BIN_NAME_CS=$BIN_NAME_CS" >> $GITHUB_ENV
78+
echo "BIN_NAME_CS=$BIN_NAME_CS"
79+
echo "BIN_NAME_SB=$BIN_NAME_SB" >> $GITHUB_ENV
80+
echo "BIN_NAME_SB=$BIN_NAME_SB"
81+
82+
mv ./target/dist/cql-stress-cassandra-stress ./target/dist/$BIN_NAME_CS
83+
mv ./target/dist/cql-stress-scylla-bench ./target/dist/$BIN_NAME_SB
84+
shell: bash
85+
86+
- name: Get Release Upload URL
87+
run: |
88+
UPLOAD_URL=$(gh release view ${{ needs.get_tag.outputs.tag }} --json uploadUrl -q '.uploadUrl' | sed 's/{.*//')
89+
echo "UPLOAD_URL=${UPLOAD_URL}?name=${{ needs.get_tag.outputs.tag }}" >> $GITHUB_ENV
90+
env:
91+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: Upload Release Asset
94+
id: upload-release-asset-cs
95+
uses: actions/upload-release-asset@v1
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
with:
99+
upload_url: ${{ env.UPLOAD_URL }}
100+
asset_path: ./target/dist/cql-stress-cassandra-stress
101+
asset_name: ${{ env.BIN_NAME_CS }}
102+
asset_content_type: application/octet-stream
103+
- name: Upload Release Asset
104+
id: upload-release-asset-sb
105+
uses: actions/upload-release-asset@v1
106+
env:
107+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
with:
109+
upload_url: ${{ env.UPLOAD_URL }}
110+
asset_path: ./target/dist/cql-stress-scylla-bench
111+
asset_name: ${{ env.BIN_NAME_SB }}
112+
asset_content_type: application/octet-stream

0 commit comments

Comments
 (0)