Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multi-architecture artifacts #56

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 35 additions & 23 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,62 @@ jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
# On tag, get tag version without v (e.g. v1.0.0 -> 1.0.0, v1.1.1-beta -> 1.1.1-beta)
- name: Get tag version
id: get_version
run: |
if [[ $GITHUB_REF == "refs/tags/v"* ]]; then
echo "Found release tag"
VERSION=${GITHUB_REF/refs\/tags\/v}
VERSION=${GITHUB_REF_NAME/v}
IS_RELEASE=true
else
echo "No release tag found"
VERSION="local-build-only"
IS_RELEASE=false
fi
echo "Using version: $VERSION"
echo "Is relase: $IS_RELEASE"
echo ::set-output name=VERSION::$VERSION
# Build and test binary
echo ::set-output name=IS_RELEASE::$IS_RELEASE
- name: Checkout
uses: actions/checkout@v3
- name: Build and Test Binary
env:
CGO_ENABLED: 0
GOOS: linux
run: |
go mod download
go test -test.timeout 30s
GOOS=linux GOARCH=amd64 go build -o build/linux/amd64/scuttle -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'"
# Build Docker image
# On tag, push Docker image
go test -test.timeout 30s

mkdir -p build/artifacts
for arch in amd64 arm64
do
GOARCH=$arch go build -o build/linux/$arch/scuttle -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'"
zip -r -j build/artifacts/scuttle-linux-$arch.zip build/linux/$arch/
done
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build Docker Image
uses: docker/build-push-action@v1
uses: docker/build-push-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
repository: redboxoss/scuttle
tags: latest,${{ steps.get_version.outputs.VERSION }}
push: ${{ startsWith(github.ref, 'refs/tags/') }}
build_args: VERSION=${{ steps.get_version.outputs.VERSION }}
# On tag, Pack zip of scuttle for GitHub Release
- name: Pack
run: |
mkdir build/artifacts
zip -r -j build/artifacts/scuttle-linux-amd64.zip build/linux/amd64/
if: startsWith(github.ref, 'refs/tags/')
# On tag, Create GitHub Release
build-args: VERSION=${{ steps.get_version.outputs.VERSION }}
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
push: ${{ steps.get_version.outputs.IS_RELEASE }}
tags: |
redboxllc/scuttle:latest
redboxllc/scuttle:${{ steps.get_version.outputs.VERSION }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
if: ${{ steps.get_version.outputs.IS_RELEASE == 'true' }}
with:
files: build/artifacts/*.zip
env:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/envoy-preflight
scuttle
.vscode/*
scuttle.bbprojectd
.DS_Store
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ ARG VERSION="local"
COPY . /app
WORKDIR /app
RUN go get -d
RUN go test -test.timeout 30s
RUN CGO_ENABLED=0 go build -o scuttle -ldflags="-X 'main.Version=${VERSION}'"
RUN go test -test.timeout 30s
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o scuttle -ldflags="-X 'main.Version=${VERSION}'"

FROM scratch
COPY --from=build /app/scuttle /scuttle