@@ -2,101 +2,61 @@ name: Release
22
33on :
44 push :
5- branches :
6- - master
7- tags :
8- - ' v*.*.*'
5+ branches : ["master"]
6+ tags : ["v*.*.*"]
97
108jobs :
11- docker :
12- name : Build and publish Docker image
13- runs-on : ubuntu-latest
14- env :
15- IMAGE_REPOSITORY : ${{ github.repository }}
16- VERSION : ${{ github.ref_name }}
17- steps :
18- - name : Checkout code
19- uses : actions/checkout@v4
20- with :
21- fetch-depth : 0
22-
23- - name : Build image
24- run : |
25- docker buildx create \
26- --name multibuilder \
27- --platform linux/amd64,linux/arm64 \
28- --bootstrap --use
29- docker buildx build \
30- --platform linux/amd64,linux/arm64 \
31- -t "$IMAGE_REPOSITORY" .
32-
33- - name : Build k6 binary
34- run : |
35- docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/xk6" \
36- "$IMAGE_REPOSITORY" build latest \
37- --with github.com/grafana/xk6-sql \
38- --with github.com/grafana/xk6-output-influxdb
39- - name : Check k6 binary
40- run : |
41- ./k6 version
42- ./k6 version | grep -qz 'xk6-output-influxdb.*xk6-sql'
43-
44- - name : Log into ghcr.io
45- if : ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
46- run : |
47- echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
48-
49- - name : Log into Docker Hub
50- if : ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
51- run : |
52- echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin
53-
54- - name : Publish master image
55- if : ${{ github.ref == 'refs/heads/master' }}
56- run : |
57- echo "Publish as master"
58- docker buildx build --push \
59- --platform linux/amd64,linux/arm64 \
60- -t ${IMAGE_REPOSITORY}:master \
61- -t "ghcr.io/${IMAGE_REPOSITORY}:master" .
62-
63- - name : Publish tagged version
64- if : ${{ startsWith(github.ref, 'refs/tags/v') }}
65- run : |
66- VERSION="${VERSION#v}"
67- echo "Publish as ${VERSION}"
68- docker buildx build --push \
69- --platform linux/amd64,linux/arm64 \
70- -t ${IMAGE_REPOSITORY}:${VERSION} \
71- -t "ghcr.io/${IMAGE_REPOSITORY}:${VERSION}" .
72- # We also want to tag the latest stable version as latest
73- if [[ ! "$VERSION" =~ (RC|rc) ]]; then
74- echo "Publish as latest"
75- docker buildx build --push \
76- --platform linux/amd64,linux/arm64 \
77- -t ${IMAGE_REPOSITORY}:latest \
78- -t "ghcr.io/${IMAGE_REPOSITORY}:latest" .
79- fi
80-
81- binary :
82- if : ${{ startsWith(github.ref, 'refs/tags/v') }}
83- name : Build and attach binary artifacts
9+ release :
10+ name : Release
8411 runs-on : ubuntu-latest
8512 permissions :
8613 contents : write
8714 packages : write
8815 steps :
8916 - name : Checkout
9017 uses : actions/checkout@v4
18+
9119 - name : Set up Go
9220 uses : actions/setup-go@v5
9321 with :
94- go-version : " 1.22.x"
22+ go-version : " 1.23.x"
23+
24+ - name : Set up QEMU
25+ uses : docker/setup-qemu-action@v3
26+ with :
27+ platforms : " amd64,arm64"
28+
29+ - name : Dry Run GoReleaser
30+ uses : goreleaser/goreleaser-action@v6
31+ with :
32+ version : " ~> v2"
33+ args : release --clean --snapshot
34+
35+ - name : Test Docker Image
36+ run : |
37+ mkdir ${{ runner.temp }}/testrun
38+ cd ${{ runner.temp }}/testrun
39+ docker run --rm -u "$(id -u):$(id -g)" -v "$PWD:/xk6" ${{ github.repository }}:latest-amd64 \
40+ build --with github.com/grafana/xk6-faker
41+ ./k6 version | grep -q xk6-faker
42+
43+ - name : Login to Docker Hub
44+ uses : docker/login-action@v3
45+ with :
46+ username : ${{ secrets.DOCKER_USER }}
47+ password : ${{ secrets.DOCKER_PASS }}
48+
49+ - name : Login to GitHub Packages
50+ uses : docker/login-action@v3
51+ with :
52+ registry : ghcr.io
53+ username : ${{ github.actor }}
54+ password : ${{ secrets.GITHUB_TOKEN }}
55+
9556 - name : Run GoReleaser
9657 uses : goreleaser/goreleaser-action@v6
9758 with :
98- distribution : goreleaser
99- version : " 2.4.7"
59+ version : " ~> v2"
10060 args : release --clean
10161 env :
10262 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments