Skip to content

feat: implement initial version of p2p relay server (#1) #16

feat: implement initial version of p2p relay server (#1)

feat: implement initial version of p2p relay server (#1) #16

Workflow file for this run

name: Build and release
on:
push:
branches:
- master
permissions: write-all
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
release_exists: ${{ steps.check_release.outputs.exists }}
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 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
- name: Check if release exists
id: check_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RELEASE_URL=$(curl --silent "https://api.github.com/repos/calimero-network/relay-server/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 "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
release:
name: Release
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.release_exists == 'false'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download job artifacts
uses: actions/download-artifact@v4
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.build.outputs.version }}
files: |
README.md
artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}