Skip to content

Commit

Permalink
More fixes to building
Browse files Browse the repository at this point in the history
  • Loading branch information
Razer2015 committed Nov 10, 2022
1 parent 12782d4 commit e1fa7bc
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 8 deletions.
44 changes: 36 additions & 8 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ jobs:
# needs: test
runs-on: ${{ matrix.OS }}
env:
NAME: battlefox
BINARY_1: battlefox
BINARY_2: battlefox_discord
TARGET: ${{ matrix.TARGET }}
OS: ${{ matrix.OS }}
steps:
Expand Down Expand Up @@ -105,22 +106,36 @@ jobs:
run: cargo build --release --verbose --target $TARGET
- name: List target
run: find ./target
- name: Compress
- name: Compress battlefox
run: |
mkdir -p ./artifacts
# windows is the only OS using a different convention for executable file name
if [[ $OS =~ ^windows.*$ ]]; then
EXEC=$NAME.exe
EXEC=$BINARY_1.exe
else
EXEC=$NAME
EXEC=$BINARY_1
fi
if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
TAG=$GITHUB_REF_NAME
else
TAG=$GITHUB_SHA
fi
mv ./target/$TARGET/release/$EXEC ./$EXEC
tar -czf ./artifacts/$NAME-$TARGET-$TAG.tar.gz $EXEC
tar -czf ./artifacts/$BINARY_1-$TARGET-$TAG.tar.gz -C ./target/$TARGET/release/ $EXEC
- name: Compress battlefox_discord
run: |
mkdir -p ./artifacts
# windows is the only OS using a different convention for executable file name
if [[ $OS =~ ^windows.*$ ]]; then
EXEC=$BINARY_2.exe
else
EXEC=$BINARY_2
fi
if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
TAG=$GITHUB_REF_NAME
else
TAG=$GITHUB_SHA
fi
tar -czf ./artifacts/$BINARY_2-$TARGET-$TAG.tar.gz -C ./target/$TARGET/release/ $EXEC
- name: Archive artifact
uses: actions/upload-artifact@v2
with:
Expand Down Expand Up @@ -171,12 +186,25 @@ jobs:
- name: Build battlefox and push
uses: docker/build-push-action@v2
with:
context: .
context: ./battlefox
platforms: linux/amd64
# platforms: linux/amd64,linux/arm64
file: ./Dockerfile.cross-platform
file: ./battlefox/Dockerfile.cross-platform
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/battlefox:${{ env.COMMIT_TAG }},${{ secrets.DOCKER_USERNAME }}/battlefox:latest
build-args: |
REPO_URL=${{ github.server_url }}/${{ github.repository }}
TAG=${{ env.COMMIT_TAG }}
# Building image and pushing it to DockerHub
- name: Build battlefox_discord and push
uses: docker/build-push-action@v2
with:
context: ./battlefox_discord
platforms: linux/amd64
# platforms: linux/amd64,linux/arm64
file: ./battlefox_discord/Dockerfile.cross-platform
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/battlefox_discord:${{ env.COMMIT_TAG }},${{ secrets.DOCKER_USERNAME }}/battlefox_discord:latest
build-args: |
REPO_URL=${{ github.server_url }}/${{ github.repository }}
TAG=${{ env.COMMIT_TAG }}
20 changes: 20 additions & 0 deletions battlefox_discord/Dockerfile.cross-platform
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM curlimages/curl:latest as downloader

ARG REPO_URL
ARG TAG
ARG TARGETPLATFORM

WORKDIR /home/curl_user

RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then export ARCHITECTURE=x86_64-unknown-linux-gnu; elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then export ARCHITECTURE=aarch64-unknown-linux-gnu; else export ARCHITECTURE=aarch64-unknown-linux-gnu; fi \
&& curl -L -o battlefox_discord.tar.gz ${REPO_URL}/releases/download/${TAG}/battlefox_discord-${ARCHITECTURE}-${TAG}.tar.gz

RUN tar -xf battlefox_discord.tar.gz

FROM debian:bullseye-slim

RUN apt-get update && apt-get install -y ca-certificates

WORKDIR /app
COPY --from=downloader /home/curl_user/battlefox_discord .
CMD ["./battlefox_discord"]

0 comments on commit e1fa7bc

Please sign in to comment.