Skip to content

Commit

Permalink
ci: setup cargo check workflow, refactor build & release workflow (#2)
Browse files Browse the repository at this point in the history
* ci: setup cargo check workflow, refactor buld & release workflow

* ci: rename metadata job in build & release workflow
  • Loading branch information
fbozic authored May 6, 2024
1 parent 434fa8e commit 50c377e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 35 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
61 changes: 26 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
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 50c377e

Please sign in to comment.