diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 975afa1e..2d43e040 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -105,6 +105,8 @@ jobs: runs-on: ubuntu-latest needs: [test, lint, examples, license-check] if: startsWith(github.ref, 'refs/tags/') + env: + DOCKER_CLI_EXPERIMENTAL: "enabled" steps: - uses: actions/checkout@v3 with: @@ -112,6 +114,16 @@ jobs: - run: git fetch --force --tags + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GIT_TOKEN }} + - name: Set up Go uses: actions/setup-go@v4 with: @@ -125,3 +137,5 @@ jobs: args: release --clean env: GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} + GITHUB_USERNAME: ${{ github.repository_owner }} + DOCKER_USERNAME: ghcr.io/${{ github.repository_owner }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml index f2b3924a..d4625213 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -31,7 +31,7 @@ brews: description: "Postgres zero-downtime migrations made easy" license: "Apache-2.0" repository: - owner: xataio + owner: "{{ .Env.GITHUB_USERNAME }}" name: homebrew-pgroll archives: @@ -47,3 +47,39 @@ changelog: exclude: - "^docs:" - "^test:" + +dockers: + - image_templates: + - "{{ .Env.DOCKER_USERNAME }}/{{ .ProjectName }}:{{ .Tag }}-amd64" + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - --platform=linux/amd64 + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://github.com/{{ .Env.GITHUB_USERNAME }}/{{ .ProjectName }} + - --label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_USERNAME }}/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ .Date }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.licenses=AL2.0 + - image_templates: + - "{{ .Env.DOCKER_USERNAME }}/{{ .ProjectName }}:{{ .Tag }}-arm64v8" + goarch: arm64 + dockerfile: Dockerfile + use: buildx + build_flag_templates: + - --platform=linux/arm64/v8 + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://github.com/{{ .Env.GITHUB_USERNAME }}/{{ .ProjectName }} + - --label=org.opencontainers.image.source=https://github.com/{{ .Env.GITHUB_USERNAME }}/{{ .ProjectName }} + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ .Date }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.licenses=AL2.0 +docker_manifests: + - name_template: "{{ .Env.DOCKER_USERNAME }}/{{ .ProjectName }}:{{ .Tag }}" + image_templates: + - "{{ .Env.DOCKER_USERNAME }}/{{ .ProjectName }}:{{ .Tag }}-amd64" + - "{{ .Env.DOCKER_USERNAME }}/{{ .ProjectName }}:{{ .Tag }}-arm64v8" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..5591935f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +COPY pgroll /usr/bin/pgroll +ENTRYPOINT [ "/usr/bin/pgroll" ] \ No newline at end of file