Skip to content

Commit

Permalink
Merge pull request #18 from numary/fix/ci-cgo-mac
Browse files Browse the repository at this point in the history
Add CGO in actions builds
  • Loading branch information
altitude authored Jul 20, 2021
2 parents e026a62 + f3c01b7 commit cfbb99a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 42 deletions.
25 changes: 25 additions & 0 deletions .github/.goreleaser.darwin.yml
Original file line number Diff line number Diff line change
@@ -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-darwin.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
2 changes: 1 addition & 1 deletion .goreleaser.yml → .github/.goreleaser.linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ before:
- go build -o numary
builds:
- env:
- CGO_ENABLED=0
- CGO_ENABLED=1
goos:
- linux
goarch:
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
36 changes: 24 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -43,27 +47,34 @@ 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}}
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 --skip-validate

- 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/[email protected]
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
Expand All @@ -73,7 +84,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: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:latest
FROM archlinux:latest

ADD dist/ledger_linux_amd64/numary /usr/local/bin/numary

Expand Down

0 comments on commit cfbb99a

Please sign in to comment.