From cdcfbd7799596efa622c8f9a9784ed9b9efc6168 Mon Sep 17 00:00:00 2001 From: "Simon B. Gasse" Date: Sat, 17 Feb 2024 13:19:26 +0100 Subject: [PATCH] Add CI workflow --- .github/workflows/github-actions.yml | 60 ++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/github-actions.yml diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 0000000..1457086 --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,60 @@ +name: CI Workflow + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ${{ matrix.runner }} + strategy: + matrix: + include: + # Linux + - name: linux-amd64 + runner: ubuntu-latest + target: x86_64-unknown-linux-gnu + command: cargo + # Android + - name: android-arm + runner: ubuntu-latest + target: aarch64-linux-android + command: cross + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install rust + uses: dtolnay/rust-toolchain@stable + + - name: Install cross + if: matrix.command == 'cross' + shell: bash + run: | + cargo install cross --git https://github.com/cross-rs/cross + + - name: Build binary + run: ${{ matrix.command }} build --release --target ${{ matrix.target }} + + - name: Create archive + if: startsWith(github.ref, 'refs/tags/') + id: archive + shell: bash + run: | + DIRECTORY="loadtimer-${{ github.ref_name }}-${{ matrix.build }}" + mkdir "${DIRECTORY}" + cp target/${{ matrix.target }}/release/loadtimer "${DIRECTORY}/" + 7z a "${DIRECTORY}.zip" "${DIRECTORY}" + echo "path=${DIRECTORY}.zip" >> ${GITHUB_OUTPUT} + + - name: Release + if: startsWith(github.ref, 'refs/tags/') + env: + GH_TOKEN: ${{ github.token }} + run: gh release upload ${{ github.ref_name }} ${{ steps.archive.outputs.path }}