From 1ddbe1702e560968bf9c321e78fb7b73c8b0fe23 Mon Sep 17 00:00:00 2001 From: Esteban Blanc Date: Mon, 21 Dec 2020 18:46:09 +0100 Subject: [PATCH] ci: Add release build (#106) * ci: Build target aware * ci: Add release.yml --- .github/workflows/build_and_test.yml | 32 ++++++++++++++++--- .github/workflows/release.yml | 46 ++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index ef3f772..6e4d100 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -22,22 +22,46 @@ jobs: tests: runs-on: ubuntu-latest + strategy: + matrix: + target: [x86_64-unknown-linux-gnu] steps: - uses: actions/checkout@v2 + + - name: Rustup setup + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + default: true + target: ${{ matrix.target }} + - name: Unit tests run: | - cargo test + cargo test --target ${{ matrix.target }} build: - runs-on: ubuntu-latest needs: [lint, tests] + runs-on: ubuntu-latest + strategy: + matrix: + target: [x86_64-unknown-linux-gnu] + steps: - uses: actions/checkout@v2 + + - name: Rustup setup + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + default: true + target: ${{ matrix.target }} + - name: Check run: | - cargo check + cargo check --target ${{ matrix.target }} + - name: Build run: | - cargo build + cargo build --target ${{ matrix.target }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..aefa583 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: Release upload artifact + +on: + release: + types: [published, edited] +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + target: [x86_64-unknown-linux-gnu] + + steps: + - uses: actions/checkout@v2 + + - name: Rustup setup + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + default: true + target: ${{ matrix.target }} + + - name: Build release + run: | + cargo build --release --target ${{ matrix.target }} + + - name: Retrive tag + id: retrive_tag + run: | + echo "##[set-output name=tag;]$(echo ${GITHUB_REF} | cut -d / -f3)" + + - name: Find upload URL + id: upload_url + run: | + echo "##[set-output name=url;] $(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/skallwar/suckit/releases/tags/${{ steps.retrive_tag.outputs.tag }} | jq .upload_url -r)" + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.upload_url.outputs.url}} + asset_path: ./target/${{ matrix.target }}/release/suckit + asset_name: suckit-${{ steps.retrive_tag.outputs.tag }}-${{ matrix.target }} + asset_content_type: application/x-elf