diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6425c3d..b8159f5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,23 +22,21 @@ jobs: release_name: Release ${{ github.ref }} draft: false prerelease: false - build_x86_64: - name: Upload Release x86-64 + upload_release: + name: Upload Release needs: create_release - runs-on: ubuntu-latest strategy: matrix: - include: - - target: x86_64-unknown-linux-gnu - cc: gcc + arch: [x86_64, aarch64] + runs-on: ${{ fromJson('{"x86_64":"ubuntu-latest", "aarch64":["self-hosted", "Linux", "ARM64"]}')[matrix.arch] }} 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_BUILDKIT=1 docker build --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 + tar -czvf ./tproxy-${{ matrix.arch }}.tar.gz ./tproxy - name: Upload Release Asset id: upload-release-asset uses: actions/upload-release-asset@v1 @@ -46,47 +44,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.create_release.outputs.upload_url }} - asset_path: ./tproxy-${{ matrix.target }}.tar.gz - asset_name: tproxy-${{ matrix.target }}.tar.gz + asset_path: ./tproxy-${{ matrix.arch }}.tar.gz + asset_name: tproxy-${{ matrix.arch }}.tar.gz asset_content_type: application/zip - build_aarch64: - name: Upload Release aarch64 - needs: create_release - runs-on: ubuntu-latest - strategy: - matrix: - include: - - target: aarch64-unknown-linux-gnu - cc: gcc-aarch64-linux-gnu - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Build - uses: uraimo/run-on-arch-action@v2 - with: - arch: aarch64 - distro: ubuntu20.04 - githubToken: ${{ secrets.GITHUB_TOKEN }} - setup: | - mkdir -p $HOME/tproxy - dockerRunArgs: | - --volume "$HOME/tproxy:/tproxy" - run: | - apt update - apt install build-essential ${{ matrix.cc }} curl git pkg-config -y - rm -rf /var/lib/apt/lists/* - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - source $HOME/.cargo/env - cargo build --release --all - cp ./target/release/chaos-tproxy /tproxy/tproxy - tar -czvf /tproxy/tproxy-${{ matrix.target }}.tar.gz /tproxy/tproxy - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ needs.create_release.outputs.upload_url }} - asset_path: $HOME/tproxy-${{ matrix.target }}.tar.gz - asset_name: tproxy-${{ matrix.target }}.tar.gz - asset_content_type: application/zip \ No newline at end of file + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ac1c168..696da42 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,6 @@ 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 @@ -18,26 +17,16 @@ RUN apt-get update && apt-get install build-essential $CC curl git pkg-config -y RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y ENV PATH "/root/.cargo/bin:${PATH}" -RUN rustup toolchain install nightly-$TARGET -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 + cargo build --release --all RUN --mount=type=cache,target=/tproxy-build/target \ - cp /tproxy-build/target/$TARGET/release/chaos-tproxy /tproxy + cp /tproxy-build/target/release/chaos-tproxy /tproxy