Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
build: GoReleaser for compiling
Browse files Browse the repository at this point in the history
Converting to using GoReleaser for compiling to easily support and simply the
supporting numerous target architectures for the binaries.

* https://github.com/goreleaser/goreleaser
  • Loading branch information
DeveloperC286 committed Dec 30, 2023
1 parent f74686f commit 8e7e3b3
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,16 @@ jobs:
uses: actions/checkout@v3
- name: Check modules.
run: earthly --ci +check-modules
compile-darwin-amd64:
name: Compile Darwin AMD64
compile:
name: Compile
runs-on: ubuntu-latest
steps:
- name: Download Earthly v0.7.17.
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.7.17/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Checkout code.
uses: actions/checkout@v3
- name: Compile Darwin AMD64.
run: earthly --ci +compile-darwin-amd64
compile-linux-amd64:
name: Compile Linux AMD64
runs-on: ubuntu-latest
steps:
- name: Download Earthly v0.7.17.
run: "sudo /bin/sh -c 'wget https://github.com/earthly/earthly/releases/download/v0.7.17/earthly-linux-amd64 -O /usr/local/bin/earthly && chmod +x /usr/local/bin/earthly'"
- name: Checkout code.
uses: actions/checkout@v3
- name: Compile Linux AMD64.
run: earthly --ci +compile-linux-amd64
- name: Compile.
run: earthly --ci +compile
unit-test:
name: Unit Test
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@

# Generated by Go coverage.
*.out

# Generated by GoReleaser.
dist/
11 changes: 11 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 1

builds:
- id: starling-bank-technical-challenge
main: ./cmd/starling-bank-technical-challenge
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
26 changes: 11 additions & 15 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ COPY_CI_DATA:
COMMAND
COPY "./ci" "./ci"
COPY ".github" ".github"
COPY ".goreleaser.yaml" ".goreleaser.yaml"


COPY_METADATA:
Expand Down Expand Up @@ -47,12 +48,6 @@ COPY_SOURCECODE:
COPY "./api" "./api"


SAVE_OUTPUT:
COMMAND
SAVE ARTIFACT "starling-bank-technical-challenge" AS LOCAL "starling-bank-technical-challenge"
SAVE ARTIFACT "go.sum" AS LOCAL "go.sum"


golang-base:
FROM golang:1.20.4
WORKDIR /tmp/starling-bank-technical-challenge
Expand Down Expand Up @@ -174,21 +169,22 @@ fix-modules:
SAVE ARTIFACT "go.sum" AS LOCAL "go.sum"


compile-linux-amd64:
FROM +golang-base
DO +INSTALL_DEPENDENCIES
DO +COPY_SOURCECODE
RUN ./ci/compile.sh
DO +SAVE_OUTPUT
INSTALL_GORELEASER:
COMMAND
ENV GORELEASER_VERSION=1.22.1
RUN wget "https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/goreleaser_Linux_x86_64.tar.gz"
RUN tar -xzvf "goreleaser_Linux_x86_64.tar.gz"
RUN cp "goreleaser" /bin/goreleaser


compile-darwin-amd64:
compile:
FROM +golang-base
ENV GOOS=darwin
DO +INSTALL_GORELEASER
DO +INSTALL_DEPENDENCIES
DO +COPY_SOURCECODE
RUN ./ci/compile.sh
DO +SAVE_OUTPUT
SAVE ARTIFACT "dist" AS LOCAL "dist"
SAVE ARTIFACT "go.sum" AS LOCAL "go.sum"


unit-test:
Expand Down
2 changes: 1 addition & 1 deletion ci/check-yaml-formatting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -o errexit
set -o xtrace

yamlfmt -lint -dstar .github/**/*
yamlfmt -lint -dstar .github/**/* .goreleaser.yaml
2 changes: 1 addition & 1 deletion ci/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -o errexit
set -o xtrace

go build "./cmd/starling-bank-technical-challenge"
goreleaser build --snapshot --clean
2 changes: 1 addition & 1 deletion ci/fix-yaml-formatting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
set -o errexit
set -o xtrace

yamlfmt -dstar ./github/**/*
yamlfmt -dstar ./github/**/* .goreleaser.yaml

0 comments on commit 8e7e3b3

Please sign in to comment.