Skip to content

Commit 434fa8e

Browse files
authored
feat: implement initial version of p2p relay server (#1)
* feat: implement initial version of p2p relay server * ci: implement github action to build and release binaries for all platforms
1 parent 5afe41b commit 434fa8e

File tree

5 files changed

+3646
-0
lines changed

5 files changed

+3646
-0
lines changed

.github/workflows/release.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build and release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
permissions: write-all
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ubuntu-latest
11+
outputs:
12+
version: ${{ steps.get_version.outputs.version }}
13+
release_exists: ${{ steps.check_release.outputs.exists }}
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup rust toolchain
19+
run: rustup toolchain install stable --profile minimal
20+
21+
- name: Setup rust cache
22+
uses: Swatinem/rust-cache@v2
23+
24+
- name: Install cross
25+
run: cargo install cross --version 0.2.5
26+
27+
- name: Build for Intel Linux
28+
run: cargo build --release --target=x86_64-unknown-linux-gnu
29+
30+
- name: Build for ARM Linux
31+
run: cross build --release --target=armv7-unknown-linux-gnueabihf
32+
33+
- name: Create artifacts directory
34+
run: |
35+
mkdir -p artifacts
36+
cp target/x86_64-unknown-linux-gnu/release/relay-server artifacts/relay-server-x86_64-unknown-linux
37+
cp target/armv7-unknown-linux-gnueabihf/release/relay-server artifacts/relay-server-armv7-unknown-linux
38+
39+
- name: Upload job artifacts
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: artifacts
43+
path: artifacts/
44+
45+
- name: Get version
46+
id: get_version
47+
run: echo "version=$(cargo read-manifest | jq -r '.version')" >> $GITHUB_OUTPUT
48+
49+
- name: Check if release exists
50+
id: check_release
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
run: |
54+
RELEASE_URL=$(curl --silent "https://api.github.com/repos/calimero-network/relay-server/releases/tags/${{ steps.get_version.outputs.version }}" \
55+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
56+
-H "Accept: application/vnd.github.v3+json" | jq -r '.url')
57+
if [[ "$RELEASE_URL" != "null" ]]; then
58+
echo "exists=true" >> $GITHUB_OUTPUT
59+
else
60+
echo "exists=false" >> $GITHUB_OUTPUT
61+
fi
62+
63+
release:
64+
name: Release
65+
runs-on: ubuntu-latest
66+
needs: build
67+
if: needs.build.outputs.release_exists == 'false'
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
72+
- name: Download job artifacts
73+
uses: actions/download-artifact@v4
74+
75+
- name: Create GitHub Release
76+
uses: softprops/action-gh-release@v2
77+
with:
78+
tag_name: ${{ needs.build.outputs.version }}
79+
files: |
80+
README.md
81+
artifacts/*
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.idea/
2+
res/
3+
data/
4+
target/
5+
.DS_Store
6+
.vscode/
7+
8+
private.key

0 commit comments

Comments
 (0)