Skip to content

Commit f131308

Browse files
fbozicmiraclx
andauthored
feat: implement dcutr example and release automation (#4)
* feat: implement dcutr example and release automation * feat: use block_on from futures * merge with workspace * add `peers` command * print conn count * chore: cleanup futures, adjust release workflow for the rust workspace * colorz * no panic * ci: remove test branch from trigger --------- Co-authored-by: Miraculous Owonubi <omiraculous@gmail.com>
1 parent 3ea6d25 commit f131308

File tree

5 files changed

+433
-7
lines changed

5 files changed

+433
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build and release dcutr example
2+
on:
3+
push:
4+
branches:
5+
- master
6+
permissions: write-all
7+
jobs:
8+
metadata:
9+
name: Get release metadata
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: Get version
19+
id: get_version
20+
run: echo "version=dcutr-example-$(cargo read-manifest --manifest-path examples/dcutr/Cargo.toml | jq -r '.version')" >> $GITHUB_OUTPUT
21+
22+
- name: Check if release exists
23+
id: check_release
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
run: |
27+
RELEASE_URL=$(curl --silent "https://api.github.com/repos/calimero-network/relay-server/releases/tags/${{ steps.get_version.outputs.version }}" \
28+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
29+
-H "Accept: application/vnd.github.v3+json" | jq -r '.url')
30+
if [[ "$RELEASE_URL" != "null" ]]; then
31+
echo "exists=true" >> $GITHUB_OUTPUT
32+
else
33+
echo "exists=false" >> $GITHUB_OUTPUT
34+
fi
35+
36+
release:
37+
name: Build and release
38+
runs-on: ubuntu-latest
39+
needs: metadata
40+
if: needs.metadata.outputs.release_exists == 'false'
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Setup rust toolchain
46+
run: rustup toolchain install stable --profile minimal
47+
48+
- name: Setup rust cache
49+
uses: Swatinem/rust-cache@v2
50+
51+
- name: Build for Intel Linux
52+
run: cargo build -p dcutr-example --release --target=x86_64-unknown-linux-gnu
53+
54+
- name: Build for Aarch Linux
55+
run: cross build -p dcutr-example --release --target=aarch64-unknown-linux-gnu
56+
57+
- name: Create artifacts directory
58+
run: |
59+
mkdir -p artifacts
60+
cp target/x86_64-unknown-linux-gnu/release/dcutr-example artifacts/dcutr-example-x86_64-unknown-linux
61+
cp target/aarch64-unknown-linux-gnu/release/dcutr-example artifacts/dcutr-example-aarch64-unknown-linux
62+
63+
- name: Create GitHub Release
64+
uses: softprops/action-gh-release@v2
65+
with:
66+
tag_name: ${{ needs.metadata.outputs.version }}
67+
files: |
68+
artifacts/*
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Cargo.lock

+88-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[workspace]
2+
members = [".", "examples/dcutr"]
3+
14
[package]
25
name = "relay-server"
36
version = "0.2.0"

examples/dcutr/Cargo.toml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[package]
2+
name = "dcutr-example"
3+
version = "0.1.0"
4+
authors = ["Calimero Limited <info@calimero.network>"]
5+
edition = "2021"
6+
repository = "https://github.com/calimero-network/relay-server"
7+
license = "MIT OR Apache-2.0"
8+
9+
[dependencies]
10+
camino = "1.1.6"
11+
clap = { version = "4.5.4", features = ["derive", "env"] }
12+
eyre = "0.6.12"
13+
libp2p = { version = "0.53.2", features = [
14+
"dcutr",
15+
"dns",
16+
"identify",
17+
"macros",
18+
"noise",
19+
"ping",
20+
"quic",
21+
"relay",
22+
"tokio",
23+
"tcp",
24+
"tls",
25+
"yamux",
26+
] }
27+
multiaddr = "0.18.1"
28+
serde = "1.0.196"
29+
serde_json = "1.0.113"
30+
tokio = { version = "1.35.1", features = [
31+
"io-std",
32+
"macros",
33+
"rt",
34+
"rt-multi-thread",
35+
] }
36+
toml = "0.8.9"
37+
tracing = "0.1.37"
38+
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }

0 commit comments

Comments
 (0)