Skip to content

Commit

Permalink
arm64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-stc committed Feb 7, 2024
1 parent b214bbd commit 3f21b38
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
35 changes: 29 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.19.x
go-version-file: './go.mod'
- name: Checkout code
uses: actions/checkout@v3

- name: Get tag version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Build Asset (linux)
- name: Build Asset (linux/amd64)
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'" -o bin/prometheus-aws-discovery-linux-amd64 ./cmd/prometheus-aws-discovery/...
- name: Build Asset (darwin)
- name: Build Asset (darwin/amd64)
run: CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'" -o bin/prometheus-aws-discovery-darwin-amd64 ./cmd/prometheus-aws-discovery/...
- name: Build Asset (linux/arm64)
run: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'" -o bin/prometheus-aws-discovery-linux-arm64 ./cmd/prometheus-aws-discovery/...
- name: Build Asset (darwin/arm64)
run: CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'" -o bin/prometheus-aws-discovery-darwin-arm64 ./cmd/prometheus-aws-discovery/...

- name: Create Release
id: create_release
Expand All @@ -38,7 +42,7 @@ jobs:
Build also available as docker image:
`daspawnw/prometheus-aws-discovery:${{ steps.get_version.outputs.VERSION }}`
- name: Upload Release Asset (linux)
- name: Upload Release Asset (linux/amd64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -47,7 +51,7 @@ jobs:
asset_path: bin/prometheus-aws-discovery-linux-amd64
asset_name: prometheus-aws-discovery-linux-amd64
asset_content_type: application/x-executable
- name: Upload Release Asset (darwin)
- name: Upload Release Asset (darwin/amd64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -56,6 +60,24 @@ jobs:
asset_path: bin/prometheus-aws-discovery-darwin-amd64
asset_name: prometheus-aws-discovery-darwin-amd64
asset_content_type: application/x-mach-binary
- name: Upload Release Asset (linux/arm64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/prometheus-aws-discovery-linux-arm64
asset_name: prometheus-aws-discovery-linux-arm64
asset_content_type: application/x-executable
- name: Upload Release Asset (darwin/arm64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: bin/prometheus-aws-discovery-darwin-arm64
asset_name: prometheus-aws-discovery-darwin-arm64
asset_content_type: application/x-mach-binary

docker:
name: Docker Push (GHCR & public ECR)
Expand All @@ -81,6 +103,7 @@ jobs:
- name: Docker publish
uses: daspawnw/docker-multi-build-push-action@master
with:
platforms: "linux/amd64,linux/arm64"
docker-tag: "${{ steps.vars.outputs.tag }}"
ghcr-enabled: "true"
ghcr-token: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.19.x
go-version-file: './go.mod'
- name: Checkout code
uses: actions/checkout@v3
- name: Test
Expand All @@ -20,9 +20,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v1
uses: actions/setup-go@v5
with:
go-version: 1.19.x
go-version-file: './go.mod'
- name: Checkout code
uses: actions/checkout@v3
- name: Calculate coverage
Expand Down Expand Up @@ -61,9 +61,10 @@ jobs:
- name: Docker publish
uses: daspawnw/docker-multi-build-push-action@master
with:
platforms: "linux/amd64,linux/arm64"
docker-tag: "${{ steps.vars.outputs.tag }}"
ghcr-enabled: "true"
ghcr-token: "${{ secrets.GITHUB_TOKEN }}"
ecr-enabled: "true"
ecr-enabled: ${{ github.repository == 'daspawnw/vault-crd' }}
ecr-role-to-assume: "${{ secrets.AWS_PUBLIC_ECR_ARN }}"
ecr-repository-url: "public.ecr.aws/l2l6k4u5/prometheus-aws-discovery"
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
FROM golang:1.19-alpine as builder
FROM --platform=$BUILDPLATFORM golang:1.19-alpine as builder

ARG TARGETOS
ARG TARGETARCH
ARG RELEASE_VERSION=development

# Install our build tools
RUN apk add --update git make bash ca-certificates

WORKDIR /go/src/github.com/daspawnw/prometheus-aws-discovery
COPY . ./
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-X 'main.Version=${RELEASE_VERSION}'" -o bin/prometheus-aws-discovery-linux-amd64 ./cmd/prometheus-aws-discovery/...
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-X 'main.Version=${RELEASE_VERSION}'" -o bin/prometheus-aws-discovery ./cmd/prometheus-aws-discovery/...

FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/src/github.com/daspawnw/prometheus-aws-discovery/bin/prometheus-aws-discovery-linux-amd64 /prometheus-aws-discovery
COPY --from=builder /go/src/github.com/daspawnw/prometheus-aws-discovery/bin/prometheus-aws-discovery /prometheus-aws-discovery

ENTRYPOINT ["/prometheus-aws-discovery"]

0 comments on commit 3f21b38

Please sign in to comment.