From 6ea3aad5127d75e7760b4023b2087d54eb4ef86b Mon Sep 17 00:00:00 2001 From: Filip Bozic <70634661+fbozic@users.noreply.github.com> Date: Mon, 6 May 2024 11:26:35 +0200 Subject: [PATCH] ci: setup cargo check workflow, refactor buld & release workflow --- .github/workflows/check.yml | 21 +++++++++++++ .github/workflows/release.yml | 59 +++++++++++++++-------------------- 2 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..1fbf719 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,21 @@ +name: Check +on: + push: + branches: + - "**" +jobs: + build: + name: Check + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup rust toolchain + run: rustup toolchain install stable --profile minimal + + - name: Setup rust cache + uses: Swatinem/rust-cache@v2 + + - name: Install cross + run: cargo check --release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8e1a4c0..52296d9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: - master permissions: write-all jobs: - build: + metadata: name: Build runs-on: ubuntu-latest outputs: @@ -15,33 +15,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup rust toolchain - run: rustup toolchain install stable --profile minimal - - - name: Setup rust cache - uses: Swatinem/rust-cache@v2 - - - name: Install cross - run: cargo install cross --version 0.2.5 - - - name: Build for Intel Linux - run: cargo build --release --target=x86_64-unknown-linux-gnu - - - name: Build for ARM Linux - run: cross build --release --target=armv7-unknown-linux-gnueabihf - - - name: Create artifacts directory - run: | - mkdir -p artifacts - cp target/x86_64-unknown-linux-gnu/release/relay-server artifacts/relay-server-x86_64-unknown-linux - cp target/armv7-unknown-linux-gnueabihf/release/relay-server artifacts/relay-server-armv7-unknown-linux - - - name: Upload job artifacts - uses: actions/upload-artifact@v4 - with: - name: artifacts - path: artifacts/ - - name: Get version id: get_version run: echo "version=$(cargo read-manifest | jq -r '.version')" >> $GITHUB_OUTPUT @@ -61,21 +34,39 @@ jobs: fi release: - name: Release + name: Build and release runs-on: ubuntu-latest - needs: build - if: needs.build.outputs.release_exists == 'false' + needs: metadata + if: needs.metadata.outputs.release_exists == 'false' steps: - name: Checkout code uses: actions/checkout@v4 - - name: Download job artifacts - uses: actions/download-artifact@v4 + - name: Setup rust toolchain + run: rustup toolchain install stable --profile minimal + + - name: Setup rust cache + uses: Swatinem/rust-cache@v2 + + - name: Install cross + run: cargo install cross --version 0.2.5 + + - name: Build for Intel Linux + run: cargo build --release --target=x86_64-unknown-linux-gnu + + - name: Build for ARM Linux + run: cross build --release --target=armv7-unknown-linux-gnueabihf + + - name: Create artifacts directory + run: | + mkdir -p artifacts + cp target/x86_64-unknown-linux-gnu/release/relay-server artifacts/relay-server-x86_64-unknown-linux + cp target/armv7-unknown-linux-gnueabihf/release/relay-server artifacts/relay-server-armv7-unknown-linux - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: - tag_name: ${{ needs.build.outputs.version }} + tag_name: ${{ needs.metadata.outputs.version }} files: | README.md artifacts/*