From 1a97afdf761c694774d426d31f0305a98e8faa06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 19 Jul 2021 18:42:00 +0200 Subject: [PATCH 1/4] add cgo in builds --- .github/workflows/main.yml | 28 ---------------------------- .github/workflows/release.yml | 34 ++++++++++++++++++++++------------ .goreleaser.yml | 3 ++- Dockerfile | 2 +- 4 files changed, 25 insertions(+), 42 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd44c7f75..a1046f4f8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,9 +26,6 @@ jobs: - uses: actions/setup-go@v2 with: go-version: '1.16' - - uses: actions/setup-python@v2 - with: - python-version: '3.9' - uses: actions/checkout@v2 - name: Configure git for private modules env: @@ -53,28 +50,3 @@ jobs: args: build --parallelism 4 --rm-dist --skip-validate --snapshot env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: eu-west-1 - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - - name: Build, tag, and push image to Amazon ECR - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: numary-preprod-ecr - IMAGE_TAG: ${{ github.sha }} - run: | - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:latest . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest - - name: Deploy new version in ECS - env: - IMAGE_TAG: ${{ github.sha }} - run: | - pip install ecs-deploy boto3 - python .github/deploy_ecs_service.py $AWS_ECS_CLUSTER $IMAGE_TAG diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0503861f4..e58511ea9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,15 +6,19 @@ permissions: contents: write jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [macos-latest, ubuntu-latest] include: - - arch: amd64 - cc: gcc + - os: macos-latest + GOOS: darwin + - os: ubuntu-latest + GOOS: linux + GOARCH: amd64 env: - GOOS: linux - GOARCH: ${{ matrix.arch }} + # GOOS: ${{ matrix.GOOS }} + # GOARCH: ${{ matrix.GOARCH }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_REGION: "eu-west-1" @@ -44,26 +48,31 @@ jobs: - name: fetch numary control run: make fetch-control - name: Run GoReleaser + env: + GOOS: ${{matrix.GOOS}} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: goreleaser/goreleaser-action@v2 with: version: latest - args: release --parallelism 2 --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Configure AWS credentials + args: release --parallelism 2 --rm-dist --single-target + + - if: matrix.os == 'ubuntu-latest' + name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: eu-west-1 - - name: Login to Amazon ECR + - if: matrix.os == 'ubuntu-latest' + name: Login to Amazon ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v1 - id: get_release uses: bruceadams/get-release@v1.2.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Build, tag, and push image to Amazon ECR + - if: matrix.os == 'ubuntu-latest' + name: Build, tag, and push image to Amazon ECR env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY: numary-prod-ecr @@ -73,7 +82,8 @@ jobs: docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:latest . docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest - - name: Deploy new version in ECS + - if: matrix.os == 'ubuntu-latest' + name: Deploy new version in ECS env: IMAGE_TAG: ${{ steps.get_release.outputs.tag_name }} run: | diff --git a/.goreleaser.yml b/.goreleaser.yml index 91cfb90b7..c965388f2 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -3,9 +3,10 @@ before: - go build -o numary builds: - env: - - CGO_ENABLED=0 + - CGO_ENABLED=1 goos: - linux + - darwin goarch: - amd64 binary: numary diff --git a/Dockerfile b/Dockerfile index db62fc737..6c22900a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:latest +FROM archlinux:latest ADD dist/ledger_linux_amd64/numary /usr/local/bin/numary From 1010cbbc05eeacd692fec38382565a3e56390e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 19 Jul 2021 18:57:36 +0200 Subject: [PATCH 2/4] multiple goreleaser config --- .github/.goreleaser.darwin.yml | 25 +++++++++++++++++++ .../.goreleaser.linux.yml | 1 - .github/workflows/release.yml | 4 ++- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .github/.goreleaser.darwin.yml rename .goreleaser.yml => .github/.goreleaser.linux.yml (96%) diff --git a/.github/.goreleaser.darwin.yml b/.github/.goreleaser.darwin.yml new file mode 100644 index 000000000..f3fec6ac1 --- /dev/null +++ b/.github/.goreleaser.darwin.yml @@ -0,0 +1,25 @@ +before: + hooks: + - go build -o numary +builds: + - env: + - CGO_ENABLED=1 + goos: + - darwin + goarch: + - amd64 + binary: numary +archives: + - replacements: + darwin: macos + amd64: x86_64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' diff --git a/.goreleaser.yml b/.github/.goreleaser.linux.yml similarity index 96% rename from .goreleaser.yml rename to .github/.goreleaser.linux.yml index c965388f2..57dbc1b50 100644 --- a/.goreleaser.yml +++ b/.github/.goreleaser.linux.yml @@ -6,7 +6,6 @@ builds: - CGO_ENABLED=1 goos: - linux - - darwin goarch: - amd64 binary: numary diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e58511ea9..2c83b2dda 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,6 +47,8 @@ jobs: run: CGO_ENABLED=1 go get - name: fetch numary control run: make fetch-control + - name: prepare goreleaser + run: cp .github/.goreleaser.${{matrix.GOOS}}.yml .goreleaser.yml - name: Run GoReleaser env: GOOS: ${{matrix.GOOS}} @@ -54,7 +56,7 @@ jobs: uses: goreleaser/goreleaser-action@v2 with: version: latest - args: release --parallelism 2 --rm-dist --single-target + args: release --parallelism 2 --rm-dist - if: matrix.os == 'ubuntu-latest' name: Configure AWS credentials From 3dcd26d953a0095258eddd746aa2c33211553121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 19 Jul 2021 19:20:50 +0200 Subject: [PATCH 3/4] fix goreleaser --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2c83b2dda..943f3eab3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,7 +56,7 @@ jobs: uses: goreleaser/goreleaser-action@v2 with: version: latest - args: release --parallelism 2 --rm-dist + args: release --parallelism 2 --rm-dist --skip-validate - if: matrix.os == 'ubuntu-latest' name: Configure AWS credentials From f3c01b7b1bf136e24ddd7fe2cfbb408724db9ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 19 Jul 2021 21:58:55 +0200 Subject: [PATCH 4/4] change name for darwin checksums --- .github/.goreleaser.darwin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/.goreleaser.darwin.yml b/.github/.goreleaser.darwin.yml index f3fec6ac1..d06f9dc31 100644 --- a/.github/.goreleaser.darwin.yml +++ b/.github/.goreleaser.darwin.yml @@ -14,7 +14,7 @@ archives: darwin: macos amd64: x86_64 checksum: - name_template: 'checksums.txt' + name_template: 'checksums-darwin.txt' snapshot: name_template: "{{ .Tag }}-next" changelog: