diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 41dadab..c22612b 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -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: @@ -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: @@ -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 }} diff --git a/battlefox_discord/Dockerfile.cross-platform b/battlefox_discord/Dockerfile.cross-platform new file mode 100644 index 0000000..80b811f --- /dev/null +++ b/battlefox_discord/Dockerfile.cross-platform @@ -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"] \ No newline at end of file