From d9866196f9863bcfceb07177a93766ecdd8d9ad1 Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Fri, 6 Jan 2023 11:42:58 +0000 Subject: [PATCH] ci: enable CGO builds --- .../{release.yaml => binary_release.yaml} | 14 +++----- .github/workflows/docker_release.yaml | 30 +++++++++++++++++ .goreleaser | 33 ------------------- .goreleaser.yaml | 21 ++++++++++++ docker-compose.build.yaml | 10 ++++++ 5 files changed, 66 insertions(+), 42 deletions(-) rename .github/workflows/{release.yaml => binary_release.yaml} (59%) create mode 100644 .github/workflows/docker_release.yaml delete mode 100644 .goreleaser create mode 100644 .goreleaser.yaml create mode 100644 docker-compose.build.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/binary_release.yaml similarity index 59% rename from .github/workflows/release.yaml rename to .github/workflows/binary_release.yaml index 85d0a3b..6a783c2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/binary_release.yaml @@ -1,4 +1,4 @@ -name: goreleaser +name: binary_release on: push: @@ -8,6 +8,8 @@ on: jobs: goreleaser: runs-on: ubuntu-latest + container: + image: goreleaser/goreleaser-cross environment: build steps: - name: Checkout @@ -18,18 +20,12 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.19.3 + go-version: 1.19 - - name: Login to Docker Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 with: version: latest - args: --parallelism 1 --rm-dist --skip-validate + args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/docker_release.yaml b/.github/workflows/docker_release.yaml new file mode 100644 index 0000000..e25ffb0 --- /dev/null +++ b/.github/workflows/docker_release.yaml @@ -0,0 +1,30 @@ +name: docker_release + +on: + push: + tags: + - "v*" + +jobs: + build-publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: docker/login-action@v1.14.1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: docker compose build push + env: + DOCKER_BUILDKIT: 1 + COMPOSE_DOCKER_CLI_BUILD: 1 + run: | + export TAG=$GITHUB_REF_NAME + docker-compose -f docker-compose.build.yaml build --progress plain + docker-compose -f docker-compose.build.yaml push + export TAG=latest + docker-compose -f docker-compose.build.yaml build --progress plain + docker-compose -f docker-compose.build.yaml push + \ No newline at end of file diff --git a/.goreleaser b/.goreleaser deleted file mode 100644 index a2ccd47..0000000 --- a/.goreleaser +++ /dev/null @@ -1,33 +0,0 @@ -builds: - - env: - - CGO_ENABLED=0 - goos: - - linux - goarch: - - amd64 - main: ./cmd - ldflags: - - -s -w - -archives: - - format: tar.gz - files: - - LICENSE - - config.toml - - queries.sql - - migrations/* - -dockers: - - goos: linux - goarch: amd64 - ids: - - cic-chain-events - image_templates: - - "ghcr.io/grassrootseconomics/cic-chain-events/cic-chain-events:latest" - - "ghcr.io/grassrootseconomics/cic-chain-events/cic-chain-events:{{ .Tag }}" - dockerfile: Dockerfile - extra_files: - - LICENSE - - config.toml - - queries.sql - - migrations/* diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..68b369f --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,21 @@ +builds: + - id: linux-amd64 + env: + - CGO_ENABLED=1 + - CC=x86_64-linux-gnu-gcc + - CXX=x86_64-linux-gnu-g++ + goos: + - linux + goarch: + - amd64 + main: ./cmd + ldflags: + - -s -w + +archives: + - format: tar.gz + files: + - LICENSE + - config.toml + - queries.sql + - migrations/ diff --git a/docker-compose.build.yaml b/docker-compose.build.yaml new file mode 100644 index 0000000..4a1e03a --- /dev/null +++ b/docker-compose.build.yaml @@ -0,0 +1,10 @@ +version: '3.9' +services: + cic-chain-events: + image: ${IMAGE_BASE_URL:-ghcr.io/grassrootseconomics/cic-chain-events}/cic-chain-events:${TAG:-latest} + build: + context: . + dockerfile: Dockerfile + cache_from: + - ${IMAGE_BASE_URL:-ghcr.io/grassrootseconomics/cic-chain-events}/cic-chain-events:latest + \ No newline at end of file