diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index d55aa07..1f15142 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -3,27 +3,32 @@ name: Build, Test, & Publish on: push: branches: [ main ] + paths-ignore: + - "**.md" + - "LICENSE" pull_request: branches: [ main ] - -env: - GO_VERSION: ~1.22 + paths-ignore: + - "**.md" + - "LICENSE" jobs: unit_tests: - name: unit tests + name: Unit tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Setup Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} - check-latest: true + go-version-file: go.mod + - name: Unit tests run: go test -v ./... + build_dev_image: - name: build dev image + name: Build dev image runs-on: ubuntu-latest needs: unit_tests permissions: @@ -31,11 +36,12 @@ jobs: id-token: 'write' steps: - uses: actions/checkout@v4 + - name: Setup Go uses: actions/setup-go@v5 with: - go-version: ${{ env.GO_VERSION }} - check-latest: true + go-version-file: go.mod + - name: OCI Metadata for multi-arch image id: meta uses: docker/metadata-action@v5 @@ -46,28 +52,35 @@ jobs: type=sha type=ref,event=pr type=semver,pattern={{version}} + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 - - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 + + - uses: docker/login-action@v3 + if: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + + # We want to always build the image, and push to registry only on new tag i.e. new release - name: Build and push uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64, linux/arm64, linux/ppc64le, linux/s390x - push: ${{ github.event_name != 'pull_request' }} + push: ${{ github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + release: name: Release to GitHub Releases - runs-on: ubunut-latest + runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') needs: [ unit_tests, build_dev_image ] steps: - uses: actions/checkout@v4 + - name: Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/v')