Skip to content

Commit

Permalink
ci: setup cargo check workflow, refactor buld & release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fbozic committed May 6, 2024
1 parent 434fa8e commit 6ea3aad
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 34 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -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
59 changes: 25 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- master
permissions: write-all
jobs:
build:
metadata:
name: Build
runs-on: ubuntu-latest
outputs:
Expand All @@ -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
Expand All @@ -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/*
Expand Down

0 comments on commit 6ea3aad

Please sign in to comment.