Skip to content

Commit

Permalink
ci: implement github action to build binaries for all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
fbozic committed Apr 29, 2024
1 parent 51c94c6 commit d84f3e0
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build and Release
on:
push:
branches:
- master
- feat/initial-implementation
jobs:
build:
name: Build and Release
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: stable
# override: true

- name: Install cross
run: cargo install cross

- name: Get version
id: get_version
run: echo "::set-output name=version::$(cargo read-manifest | jq -r '.version')"

- name: Check if release exists
id: check_release
run: |
RELEASE_URL=$(curl --silent "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/tags/${{ steps.get_version.outputs.version }}" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" | jq -r '.url')
if [[ "$RELEASE_URL" != "null" ]]; then
echo "::set-output name=exists::true"
else
echo "::set-output name=exists::false"
fi
- name: Build for Linux
uses: actions-rs/cargo@v1
if: steps.check_release.outputs.exists == 'false'
with:
command: build
args: --release --target=x86_64-unknown-linux-gnu

- name: Build for ARM Linux
run: cross build --release --target=armv7-unknown-linux-gnueabihf
if: steps.check_release.outputs.exists == 'false'

- name: Build for macOS
run: cross build --release --target=x86_64-apple-darwin
if: steps.check_release.outputs.exists == 'false'

- name: Create Release
uses: softprops/action-gh-release@v2
if: steps.check_release.outputs.exists == 'false'
with:
tag_name: ${{ steps.get_version.outputs.version }}
files: |
target/x86_64-unknown-linux-gnu/release/relay-server
target/armv7-unknown-linux-gnueabihf/release/relay-server
target/x86_64-apple-darwin/release/relay-server
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit d84f3e0

Please sign in to comment.