Merge branch 'minekube:master' into master #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ci | |
| on: | |
| push: | |
| workflow_dispatch: | |
| pull_request: | |
| types: [opened, reopened] | |
| env: | |
| REGISTRY: ghcr.io | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v6 | |
| with: | |
| version: latest | |
| install-mode: goinstall | |
| args: --timeout 3m0s | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: [ubuntu-latest, macos-latest, windows-latest] | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go with cache | |
| uses: actions/setup-go@v5 | |
| with: | |
| cache: true | |
| go-version-file: go.mod | |
| - name: Test | |
| run: make test | |
| # Regression test for https://github.com/minekube/gate/issues/697: | |
| # The published images crashed with "exec /gate: no such file or directory" | |
| # because the gate binary is dynamically linked (the geyserlite dependency | |
| # pulls in github.com/ebitengine/purego, which imports libdl.so.2 via | |
| # //go:cgo_import_dynamic even with CGO_ENABLED=0) but the runtime base image | |
| # had no glibc dynamic loader. This job builds the actual images and runs the | |
| # binary so a broken runtime base fails CI instead of shipping. | |
| docker-smoke: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up docker buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build gate image (host arch, load) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| load: true | |
| target: gate | |
| build-args: | | |
| VERSION=smoke-test | |
| tags: gate:smoke | |
| - name: Smoke test - gate binary execs in distroless image | |
| run: | | |
| out="$(docker run --rm gate:smoke --version)" | |
| echo "$out" | |
| echo "$out" | grep -q "gate version smoke-test" | |
| - name: Build jre variant image (host arch, load) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| load: true | |
| target: jre | |
| build-args: | | |
| VERSION=smoke-test | |
| tags: gate-jre:smoke | |
| - name: Smoke test - gate binary execs in jre image | |
| run: | | |
| out="$(docker run --rm gate-jre:smoke --version)" | |
| echo "$out" | |
| echo "$out" | grep -q "gate version smoke-test" | |
| build: | |
| if: ( github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/') ) || ( github.event_name == 'push' && ( github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') ) ) | |
| needs: | |
| - lint | |
| - test | |
| - docker-smoke | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image: ${{ steps.image-ref.outputs.image }} | |
| image_latest: ${{ steps.image-ref.outputs.image_latest }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up docker buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create image ref and version | |
| id: image-ref | |
| run: | | |
| REF=$(git rev-parse --short $GITHUB_SHA) | |
| # Get version from git tags or use commit-based version | |
| VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev-${REF}") | |
| IMAGE=${{ env.REGISTRY }}/${{ github.repository }}:${REF} | |
| IMAGE_LATEST=${{ env.REGISTRY }}/${{ github.repository }}:latest | |
| IMAGE_JRE=${{ env.REGISTRY }}/${{ github.repository }}/jre:${REF} | |
| IMAGE_JRE_LATEST=${{ env.REGISTRY }}/${{ github.repository }}/jre:latest | |
| echo "image=${IMAGE}" >> $GITHUB_OUTPUT | |
| echo "image_latest=${IMAGE_LATEST}" >> $GITHUB_OUTPUT | |
| echo "image_jre=${IMAGE_JRE}" >> $GITHUB_OUTPUT | |
| echo "image_jre_latest=${IMAGE_JRE_LATEST}" >> $GITHUB_OUTPUT | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| # If building from a tag, extract the version tag for docker tagging | |
| if [[ $GITHUB_REF == refs/tags/* ]]; then | |
| VERSION_TAG=${GITHUB_REF#refs/tags/} | |
| IMAGE_VERSION=${{ env.REGISTRY }}/${{ github.repository }}:${VERSION_TAG} | |
| IMAGE_JRE_VERSION=${{ env.REGISTRY }}/${{ github.repository }}/jre:${VERSION_TAG} | |
| echo "image_version=${IMAGE_VERSION}" >> $GITHUB_OUTPUT | |
| echo "image_jre_version=${IMAGE_JRE_VERSION}" >> $GITHUB_OUTPUT | |
| echo "version_tag=${VERSION_TAG}" >> $GITHUB_OUTPUT | |
| echo "Building images with version tag:" >> $GITHUB_STEP_SUMMARY | |
| echo "- ${IMAGE_VERSION}" >> $GITHUB_STEP_SUMMARY | |
| echo "- ${IMAGE_JRE_VERSION}" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "Building images:" >> $GITHUB_STEP_SUMMARY | |
| echo "- ${IMAGE}" >> $GITHUB_STEP_SUMMARY | |
| echo "- ${IMAGE_JRE}" >> $GITHUB_STEP_SUMMARY | |
| echo "Version: ${VERSION}" >> $GITHUB_STEP_SUMMARY | |
| - name: Build and push docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| cache-from: type=registry,ref=${{ steps.image-ref.outputs.image_latest }} | |
| cache-to: type=inline | |
| build-args: | | |
| VERSION=${{ steps.image-ref.outputs.version }} | |
| target: gate | |
| tags: | | |
| ${{ steps.image-ref.outputs.image }} | |
| ${{ steps.image-ref.outputs.image_latest }} | |
| ${{ steps.image-ref.outputs.image_version }} | |
| - name: Build and push docker image (jre variant) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| cache-from: type=registry,ref=${{ steps.image-ref.outputs.image_jre_latest }} | |
| cache-to: type=inline | |
| build-args: | | |
| VERSION=${{ steps.image-ref.outputs.version }} | |
| target: jre | |
| tags: | | |
| ${{ steps.image-ref.outputs.image_jre }} | |
| ${{ steps.image-ref.outputs.image_jre_latest }} | |
| ${{ steps.image-ref.outputs.image_jre_version }} | |
| releaser: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| cache: true | |
| go-version-file: go.mod | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| version: latest | |
| args: release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |