diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..be508a6 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,54 @@ +name: Build and publish xk6-kafka + +on: + push: + tags: + - "v*" + +jobs: + build: + name: Build xk6-kafka + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + 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@latest + + - name: Create Release 📦 + uses: softprops/action-gh-release@v1 + with: + files: dist/*.tar.gz + + - name: Docker meta 📝 + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ steps.build.outputs.name }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Login to DockerHub 🔒 + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Docker build and push ☁️ + if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@v2 + with: + push: true + context: ./${{ steps.build.outputs.dockerdir }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}