Skip to content

Commit

Permalink
release aarch64 on self-hosted native machine
Browse files Browse the repository at this point in the history
Signed-off-by: xixi <i@hexilee.me>
  • Loading branch information
Hexilee committed May 16, 2022
1 parent c9f9290 commit adb39a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 64 deletions.
60 changes: 9 additions & 51 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,71 +22,29 @@ 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
env:
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

15 changes: 2 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit adb39a1

Please sign in to comment.