From 618043aab4cf06d4a9dbe22688d059f4172b6a07 Mon Sep 17 00:00:00 2001 From: Amir Ahmad <4963254+Amir-Ahmad@users.noreply.github.com> Date: Sun, 4 Jun 2023 14:12:41 +1000 Subject: [PATCH] Add Goreleaser, Dockerfile and GH Action --- .github/workflows/release.yaml | 54 ++++++++++++++++++++++++++++++++++ .gitignore | 1 + .goreleaser.yaml | 34 +++++++++++++++++++++ Dockerfile | 14 +++++++++ 4 files changed, 103 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .goreleaser.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4aa2526 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,54 @@ +name: release + +on: + push: + tags: + - "v*" + +permissions: + contents: write + packages: write + +jobs: + build-and-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.20" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + platforms: linux/amd64,linux/arm64 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/amir-ahmad/cuemix + tags: | + type=semver,pattern={{version}} + type=sha,prefix= + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v4 + with: + distribution: goreleaser + version: latest + args: release + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.gitignore b/.gitignore index 63fea4f..6cf453f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .charts/ bin/ +dist/ # Binaries for programs and plugins *.exe diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..72107b0 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,34 @@ +project_name: cuemix + +builds: + - env: + - CGO_ENABLED=0 + main: cmd/main.go + ldflags: + - -s -w -X "github.com/amir-ahmad/cuemix/cmd/cuemix.version={{ .Version }}" + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + ignore: + - goos: windows + goarch: arm64 + binary: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" + no_unique_dist_dir: true + +archives: + - format: tar.gz + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ incpatch .Version }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c9bcbf0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM cuelang/cue:0.5.0 as cue + +FROM alpine:3.18.0 + +ARG TARGETARCH + +COPY "dist/cuemix_linux_${TARGETARCH}" /usr/bin/cuemix +COPY --from=cue /usr/bin/cue /usr/bin/cue + +RUN apk add --no-cache git + +WORKDIR /app + +ENTRYPOINT ["cuemix"]