Skip to content

Commit

Permalink
cherry-pick(#15) add aarch64 release in ci (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexilee authored Sep 14, 2021
1 parent a06d3e6 commit a018a1e
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 11 deletions.
37 changes: 26 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ on:
name: Create Release

jobs:
build:
create_release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build
run: cargo build --release
- name: Pack
run: mv ./target/release/tproxy . && tar -czvf ./tproxy.tar.gz tproxy
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -26,13 +22,32 @@ jobs:
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
build:
name: Upload Release
needs: create_release
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: aarch64-unknown-linux-gnu
cc: gcc-aarch64-linux-gnu
- target: x86_64-unknown-linux-gnu
cc: gcc
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build
run: |
DOCKER_BUILDKIT=1 docker build --build-arg CC=${{ matrix.cc }} --build-arg TARGET=${{ matrix.target }} --build-arg HTTP_PROXY=${HTTP_PROXY} --build-arg HTTPS_PROXY=${HTTPS_PROXY} . -t chaos-mesh/tproxy
docker run -v ${PWD}:/opt/mount:z --rm --entrypoint cp chaos-mesh/tproxy /tproxy /opt/mount/tproxy
tar -czvf ./tproxy-${{ matrix.target }}.tar.gz ./tproxy
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./tproxy.tar.gz
asset_name: tproxy-linux-amd64.tar.gz
asset_content_type: application/zip
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./tproxy-${{ matrix.target }}.tar.gz
asset_name: tproxy-${{ matrix.target }}.tar.gz
asset_content_type: application/zip
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

# syntax=docker/dockerfile:experimental

FROM debian:buster-slim

ENV DEBIAN_FRONTEND noninteractive

ARG HTTPS_PROXY
ARG HTTP_PROXY
ARG TARGET=x86_64-unknown-linux-gnu
ARG CC=gcc

ENV http_proxy $HTTP_PROXY
ENV https_proxy $HTTPS_PROXY

RUN apt-get update && apt-get install build-essential $CC curl git pkg-config -y && rm -rf /var/lib/apt/lists/*

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH "/root/.cargo/bin:${PATH}"

RUN rustup target add $TARGET

RUN if [ -n "$HTTP_PROXY" ]; then echo "[http]\n\
proxy = \"${HTTP_PROXY}\"\n\
"\
>> /root/.cargo/config ; fi

RUN echo "[target.aarch64-unknown-linux-gnu]\n\
linker = \"aarch64-linux-gnu-gcc\"\n\
"\
>> /root/.cargo/config

COPY . /tproxy-build

WORKDIR /tproxy-build

RUN --mount=type=cache,target=/tproxy-build/target \
--mount=type=cache,target=/root/.cargo/registry \
cargo build --release --all --target $TARGET

RUN --mount=type=cache,target=/tproxy-build/target \
cp /tproxy-build/target/$TARGET/release/tproxy /tproxy

0 comments on commit a018a1e

Please sign in to comment.