diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 518aaa3..e593edb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,29 +1,41 @@ -name: Publish to Docker Hub +name: Publish to GitHub Container Registry on: release: types: [published] jobs: update: runs-on: ubuntu-latest - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true steps: - name: Checkout Repository uses: actions/checkout@v4 - - name: Get release version - id: get_version - run: echo ::set-env name=RELEASE_VERSION::$(echo $GITHUB_REF | cut -d / -f 3) + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: jacobtomlinson/gha-find-replace + tags: | + type=semver,pattern={{version}} + type=semver,pattern=v{{major}} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Publish to Registry - uses: elgohr/Publish-Docker-Github-Action@v5 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 with: - name: jacobtomlinson/gha-find-replace + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - registry: ghcr.io - tags: "latest,${{ env.RELEASE_VERSION }}" + + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + annotations: ${{ steps.meta.outputs.annotations }} platforms: linux/amd64,linux/arm64 diff --git a/Dockerfile b/Dockerfile index a267747..9b4b959 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /app COPY . /app # Statically compile our app for use in a distroless container -RUN CGO_ENABLED=0 go build -ldflags="-w -s" -v -o app . +RUN CGO_ENABLED=0 go build -ldflags="-w -s" -trimpath -v -o app . # A distroless container image with some basics like SSL certificates # https://github.com/GoogleContainerTools/distroless