diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bfd7d95..e782fef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,3 +19,31 @@ jobs: ./bin/dotkatapult --port=8080 & curl --silent --retry 10 --retry-delay 1 --retry-connrefused \ http://localhost:8080/ + + release: + runs-on: ubuntu-latest + needs: [test] + if: startsWith(github.ref, 'refs/tags/v') + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - uses: docker/setup-buildx-action@v1 + - name: Docker Login + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/setup-go@v2 + with: + go-version: 1.18 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..d122db6 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,100 @@ +before: + hooks: + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + mod_timestamp: "{{ .CommitTimestamp }}" + flags: + - -trimpath + ldflags: + - "-s -w" + goos: + - "darwin" + - "freebsd" + - "linux" + - "windows" + goarch: + - "amd64" + - "386" + - "arm" + - "arm64" + goarm: + - "6" + - "7" + +checksum: + name_template: "checksums.txt" +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + +dockers: + - image_templates: + - "ghcr.io/jimeh/dotkatapult:{{ .Version }}-amd64" + - "ghcr.io/jimeh/dotkatapult:latest-amd64" + dockerfile: Dockerfile.goreleaser + use: buildx + goos: linux + goarch: amd64 + build_flag_templates: + - "--platform=linux/amd64" + - image_templates: + - "ghcr.io/jimeh/dotkatapult:{{ .Version }}-386" + - "ghcr.io/jimeh/dotkatapult:latest-386" + dockerfile: Dockerfile.goreleaser + use: buildx + goos: linux + goarch: "386" + build_flag_templates: + - "--platform=linux/386" + - image_templates: + - "ghcr.io/jimeh/dotkatapult:{{ .Version }}-arm64" + - "ghcr.io/jimeh/dotkatapult:latest-arm64" + use: buildx + goos: linux + goarch: arm64 + dockerfile: Dockerfile.goreleaser + build_flag_templates: + - "--platform=linux/arm64" + - image_templates: + - "ghcr.io/jimeh/dotkatapult:{{ .Version }}-armv6" + - "ghcr.io/jimeh/dotkatapult:latest-armv6" + use: buildx + goos: linux + goarch: arm + goarm: "6" + dockerfile: Dockerfile.goreleaser + build_flag_templates: + - "--platform=linux/arm/v6" + - image_templates: + - "ghcr.io/jimeh/dotkatapult:{{ .Version }}-armv7" + - "ghcr.io/jimeh/dotkatapult:latest-armv7" + use: buildx + goos: linux + goarch: arm + goarm: "7" + dockerfile: Dockerfile.goreleaser + build_flag_templates: + - "--platform=linux/arm/v7" + +docker_manifests: + - name_template: ghcr.io/jimeh/dotkatapult:{{ .Version }} + image_templates: + - ghcr.io/jimeh/dotkatapult:{{ .Version }}-amd64 + - ghcr.io/jimeh/dotkatapult:{{ .Version }}-386 + - ghcr.io/jimeh/dotkatapult:{{ .Version }}-arm64 + - ghcr.io/jimeh/dotkatapult:{{ .Version }}-armv6 + - ghcr.io/jimeh/dotkatapult:{{ .Version }}-armv7 + - name_template: ghcr.io/jimeh/dotkatapult:latest + image_templates: + - ghcr.io/jimeh/dotkatapult:latest-amd64 + - ghcr.io/jimeh/dotkatapult:latest-386 + - ghcr.io/jimeh/dotkatapult:latest-arm64 + - ghcr.io/jimeh/dotkatapult:latest-armv6 + - ghcr.io/jimeh/dotkatapult:latest-armv7 diff --git a/Dockerfile.goreleaser b/Dockerfile.goreleaser new file mode 100644 index 0000000..a08e644 --- /dev/null +++ b/Dockerfile.goreleaser @@ -0,0 +1,6 @@ +FROM scratch +COPY ./dotkatapult / +ENV PORT 8080 +EXPOSE 8080 +WORKDIR / +CMD ["/dotkatapult"]