-
Notifications
You must be signed in to change notification settings - Fork 21
81 lines (72 loc) · 2.62 KB
/
release.yml
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
name: Release
on:
push:
branches:
- master
tags:
- 'v*.*.*'
pull_request:
jobs:
docker:
name: Build and publish Docker image
runs-on: ubuntu-latest
env:
IMAGE_REPOSITORY: ${{ github.repository }}
VERSION: ${{ github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build image
run: |
docker buildx create \
--name multibuilder \
--platform linux/amd64,linux/arm64 \
--bootstrap --use
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t "$IMAGE_REPOSITORY" .
- name: Build k6 binary
run: |
docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/xk6" \
"$IMAGE_REPOSITORY" build master \
--with github.com/grafana/xk6-sql \
--with github.com/grafana/xk6-output-influxdb
- name: Check k6 binary
run: |
./k6 version
./k6 version | grep -qz 'xk6-output-influxdb.*xk6-sql'
- name: Log into ghcr.io
if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
- name: Log into Docker Hub
if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
run: |
echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin
- name: Publish master image
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "Publish as master"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t ${IMAGE_REPOSITORY}:master \
-t "ghcr.io/${IMAGE_REPOSITORY}:master" .
- name: Publish tagged version
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
VERSION="${VERSION#v}"
echo "Publish as ${VERSION}"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t ${IMAGE_REPOSITORY}:${VERSION} \
-t "ghcr.io/${IMAGE_REPOSITORY}:${VERSION}" .
# We also want to tag the latest stable version as latest
if [[ ! "$VERSION" =~ (RC|rc) ]]; then
echo "Publish as latest"
docker buildx build --push \
--platform linux/amd64,linux/arm64 \
-t ${IMAGE_REPOSITORY}:latest \
-t "ghcr.io/${IMAGE_REPOSITORY}:latest" .
fi