From 50c377e2f07351607110e5a3994b7363c2b86af8 Mon Sep 17 00:00:00 2001 From: Filip Bozic <70634661+fbozic@users.noreply.github.com> Date: Mon, 6 May 2024 15:09:46 +0200 Subject: [PATCH] ci: setup cargo check workflow, refactor build & release workflow (#2) * ci: setup cargo check workflow, refactor buld & release workflow * ci: rename metadata job in build & release workflow --- .github/workflows/check.yml | 21 ++++++++++++ .github/workflows/release.yml | 61 +++++++++++++++-------------------- 2 files changed, 47 insertions(+), 35 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..0788680 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,8 +5,8 @@ on: - master permissions: write-all jobs: - build: - name: Build + metadata: + name: Get release metadata runs-on: ubuntu-latest outputs: version: ${{ steps.get_version.outputs.version }} @@ -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/*