From 1a16dde8227dc482bf0007fef4e2c09d35dd4759 Mon Sep 17 00:00:00 2001 From: Yang Keao Date: Thu, 10 Sep 2020 12:06:10 +0800 Subject: [PATCH] add auto release script Signed-off-by: Yang Keao --- .dockerignore | 3 ++- .github/workflows/release.yml | 40 +++++++++++++++++++++++++++++++++++ Dockerfile | 29 +++++++++++++++---------- Makefile | 3 +++ 4 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.dockerignore b/.dockerignore index b4b592c..bf4df3f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ target .git -Dockerfile \ No newline at end of file +Dockerfile +example \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..435f109 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +on: + push: + tags: + - 'v*' + +name: Create Release + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build + run: | + make image-toda + CID=$(docker create ) + docker cp ${CID}:/toda /toda + tar -czvf /toda.tar.gz /toda + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + - 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: /toda.tar.gz + asset_name: toda-linux-amd64.tar.gz + asset_content_type: application/zip \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6474ea2..4a95ba6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,33 @@ # syntax=docker/dockerfile:experimental -FROM ubuntu:20.04 +FROM debian:buster-slim + +ENV DEBIAN_FRONTEND noninteractive ARG HTTPS_PROXY ARG HTTP_PROXY -ENV DEBIAN_FRONTEND noninteractive +ENV http_proxy $HTTP_PROXY +ENV https_proxy $HTTPS_PROXY -RUN apt-get update -RUN apt-get install libfuse-dev pkg-config fuse curl build-essential -y -RUN apt-get install gdb vim -y +RUN apt-get update && apt-get install build-essential curl git pkg-config libfuse-dev fuse -y && rm -rf /var/lib/apt/lists/* RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain nightly-2020-07-01 -y ENV PATH "/root/.cargo/bin:${PATH}" -ENV RUSTFLAGS "-Z relro-level=full" + +RUN if [ -n "$HTTP_PROXY" ]; then echo "[http]\n\ +proxy = \"${HTTP_PROXY}\"\n\ +"\ +> /root/.cargo/config ; fi + +COPY . /toda-build WORKDIR /toda-build -COPY . . +ENV RUSTFLAGS "-Z relro-level=full" +RUN --mount=type=cache,target=/toda-build/target \ + --mount=type=cache,target=/root/.cargo/registry \ + cargo build --release RUN --mount=type=cache,target=/toda-build/target \ - cargo build - -RUN --mount=type=cache,target=/toda-build/target \ - cp /toda-build/target/debug/toda /toda \ No newline at end of file + cp /toda-build/target/release/toda /toda \ No newline at end of file diff --git a/Makefile b/Makefile index 7a96aa4..09c3ae3 100644 --- a/Makefile +++ b/Makefile @@ -10,5 +10,8 @@ example: example-image volume example-inject:debug-toda cat ./io-inject-example.json|sudo -E ./target/debug/toda --path /var/run/test --pid $$(pgrep main-app) --verbose trace +image-toda: + docker build --build-arg HTTP_PROXY=${HTTP_PROXY} --build-arg HTTPS_PROXY=${HTTPS_PROXY} . -t chaos-mesh/toda + debug-toda: RUSTFLAGS="-Z relro-level=full" cargo build