Skip to content

Commit

Permalink
Replace xk6bundler with xk6
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Jun 4, 2022
1 parent 997cb71 commit fe35b61
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
28 changes: 16 additions & 12 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ jobs:
with:
fetch-depth: 0

- name: Build 🏗️
id: build
uses: szkiba/xk6bundler@v0
with:
platform: linux/amd64 windows/amd64 darwin/amd64
with: |
github.com/mostafa/xk6-kafka@${{ github.ref_name }}
- name: Install Go 🧑‍💻
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: actions/setup-go@v3
with:
go-version: '1.18'

- name: Install xk6 and build xk6-kafka for different platforms 🏗️
run: |
mkdir dist
go install go.k6.io/xk6/cmd/xk6@latest
GOOS=linux GOARCH=amd64 xk6 build --output dist/xk6-kafka_${{ github.ref_name }}_linux_amd64 --with github.com/mostafa/xk6-kafka@${{ github.ref_name }}
tar cvzf dist/xk6-kafka_${{ github.ref_name }}_linux_amd64.tar.gz dist/xk6-kafka_${{ github.ref_name }}_linux_amd64
GOOS=darwin GOARCH=amd64 xk6 build --output dist/xk6-kafka_${{ github.ref_name }}_darwin_amd64 --with github.com/mostafa/xk6-kafka@${{ github.ref_name }}
tar cvzf dist/xk6-kafka_${{ github.ref_name }}_darwin_amd64.tar.gz dist/xk6-kafka_${{ github.ref_name }}_darwin_amd64
GOOS=windows GOARCH=amd64 xk6 build --output dist/xk6-kafka_${{ github.ref_name }}_windows_amd64.exe --with github.com/mostafa/xk6-kafka@${{ github.ref_name }}
tar cvzf dist/xk6-kafka_${{ github.ref_name }}_windows_amd64.tar.gz dist/xk6-kafka_${{ github.ref_name }}_windows_amd64.exe
- name: Generate CycloneDX SBOM artifacts 📃
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
run: |
Expand All @@ -50,9 +53,9 @@ jobs:

- name: Docker meta 📝
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v4
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.build.outputs.name }}
images: mostafamoradian/xk6-kafka
tags: |
type=semver,pattern={{version}}
Expand All @@ -62,12 +65,13 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker build and push
- name: Build and push Docker image 🛳
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v2
with:
context: .
push: true
context: ./${{ steps.build.outputs.dockerdir }}
build-args: K6_BINARY=./dist/xk6-kafka_${{ github.ref_name }}_linux_amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ k6
.idea
act
__debug_bin

dist/
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM alpine
ARG K6_BINARY

RUN apk add --no-cache ca-certificates && \
adduser -D -u 12345 -g 12345 k6
COPY ${K6_BINARY} /usr/bin/k6

USER 12345
WORKDIR /home/k6
ENTRYPOINT ["k6"]

0 comments on commit fe35b61

Please sign in to comment.