From 6da4a0886f0b5399f974877db1d12fa1ae6c3982 Mon Sep 17 00:00:00 2001 From: Amir Omidi Date: Tue, 23 Nov 2021 15:12:52 -0500 Subject: [PATCH] Goreleaser (#3) --- .github/workflows/release.yml | 43 ++++++++++++++++ .github/workflows/test.yml | 33 ++++++++++++ .goreleaser.yml | 96 +++++++++++++++++++++++++++++++++++ Dockerfile | 5 ++ 4 files changed, 177 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml create mode 100644 .goreleaser.yml create mode 100644 Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bd0c8aa --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: release + +permissions: + contents: write + packages: write + statuses: write + pull-requests: read + +on: + push: + tags: + - v* + +jobs: + release: + name: release + runs-on: ubuntu-latest + + steps: + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.17 + + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Release and publish + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ba6528a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,33 @@ +name: test + +permissions: + contents: read + statuses: write + pull-requests: read + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + test: + name: test + runs-on: ubuntu-latest + + steps: + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.17 + + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Test goreleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist --skip-publish diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..7571193 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,96 @@ +before: + hooks: + - go mod download + +builds: + - &build + id: "attache-check-build" + binary: "attache-check" + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + - arm64 + goarm: + - "6" + - "7" + main: ./cmd/attache-check + + - <<: *build + id: "attache-control-build" + binary: "attache-control" + main: ./cmd/attache-control + +archives: +- replacements: + darwin: Darwin + linux: Linux + windows: Windows + "386": i386 + amd64: x86_64 + allow_different_binary_count: true + +checksum: + name_template: 'checksums.txt' + +snapshot: + name_template: "{{ .Tag }}-next" + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + +dockers: + - id: "attache-check-docker" + ids: + - "attache-check-build" + image_templates: + - "ghcr.io/letsencrypt/attache-check:{{ .Tag }}" + - "ghcr.io/letsencrypt/attache-check:v{{ .Major }}" + - "ghcr.io/letsencrypt/attache-check:v{{ .Major }}.{{ .Minor }}" + - "ghcr.io/letsencrypt/attache-check:latest" + build_flag_templates: + - "--pull" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title=attache-check" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--build-arg=BINARY_NAME=attache-check" + dockerfile: Dockerfile + - id: "attache-control-docker" + ids: + - "attache-control-build" + image_templates: + - "ghcr.io/letsencrypt/attache-control:{{ .Tag }}" + - "ghcr.io/letsencrypt/attache-control:v{{ .Major }}" + - "ghcr.io/letsencrypt/attache-control:v{{ .Major }}.{{ .Minor }}" + - "ghcr.io/letsencrypt/attache-control:latest" + build_flag_templates: + - "--pull" + - "--label=org.opencontainers.image.created={{.Date}}" + - "--label=org.opencontainers.image.title=attache-control" + - "--label=org.opencontainers.image.revision={{.FullCommit}}" + - "--label=org.opencontainers.image.version={{.Version}}" + - "--build-arg=BINARY_NAME=attache-control" + dockerfile: Dockerfile + +nfpms: + - id: attache-nfpm + package_name: attache + builds: + - attache-check-build + - attache-control-build + maintainer: Let's Encrypt + description: A sidecar that allows for effortless scaling of Redis Clusters using Hashicorp Nomad and Consul. + homepage: https://github.com/letsencrypt/attache + formats: + - deb + - rpm + - apk diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..195756f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM scratch +ARG BINARY_NAME + +COPY ${BINARY_NAME} app +ENTRYPOINT ["/app"]