-
Notifications
You must be signed in to change notification settings - Fork 20
85 lines (77 loc) · 3.28 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
81
82
83
84
85
name: Release
on:
push:
branches:
- master
tags:
- 'v*.*.*'
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@v3
with:
fetch-depth: 0
- name: Build image
run: docker build -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/mostafa/xk6-kafka \
--with github.com/grafana/xk6-output-influxdb
- name: Check k6 binary
run: |
./k6 version
./k6 version | grep -qz 'xk6-output-influxdb.*xk6-kafka'
- 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: Publish master image to ghcr.io
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "Publish as ghcr.io/${IMAGE_REPOSITORY}:master"
docker tag "$IMAGE_REPOSITORY" "ghcr.io/${IMAGE_REPOSITORY}:master"
docker push "ghcr.io/${IMAGE_REPOSITORY}:master"
- name: Publish tagged version image to ghcr.io
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
VERSION="${VERSION#v}"
echo "Publish as ghcr.io/${IMAGE_REPOSITORY}:${VERSION}"
docker tag "$IMAGE_REPOSITORY" "ghcr.io/${IMAGE_REPOSITORY}:${VERSION}"
docker push "ghcr.io/${IMAGE_REPOSITORY}:${VERSION}"
# We also want to tag the latest stable version as latest
if [[ ! "$VERSION" =~ (RC|rc) ]]; then
echo "Publish as ghcr.io/${IMAGE_REPOSITORY}:latest"
docker tag "$IMAGE_REPOSITORY" "ghcr.io/${IMAGE_REPOSITORY}:latest"
docker push "ghcr.io/${IMAGE_REPOSITORY}:latest"
fi
- 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 to Docker Hub
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "Publish as ${IMAGE_REPOSITORY}:master"
docker tag "$IMAGE_REPOSITORY" "${IMAGE_REPOSITORY}:master"
docker push "${IMAGE_REPOSITORY}:master"
- name: Publish tagged version image to Docker Hub
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
VERSION="${VERSION#v}"
echo "Publish as ${IMAGE_REPOSITORY}:${VERSION}"
docker tag "$IMAGE_REPOSITORY" "${IMAGE_REPOSITORY}:${VERSION}"
docker push "${IMAGE_REPOSITORY}:${VERSION}"
# We also want to tag the latest stable version as latest
if [[ ! "$VERSION" =~ (RC|rc) ]]; then
echo "Publish as ${IMAGE_REPOSITORY}:latest"
docker tag "$IMAGE_REPOSITORY" "${IMAGE_REPOSITORY}:latest"
docker push "${IMAGE_REPOSITORY}:latest"
fi