Skip to content

Commit

Permalink
feat: implement dcutr example and release automation (#4)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
fbozic and miraclx authored May 9, 2024
1 parent 3ea6d25 commit f131308
Show file tree
Hide file tree
Showing 5 changed files with 433 additions and 7 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/release-dcutr-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build and release dcutr example
on:
push:
branches:
- master
permissions: write-all
jobs:
metadata:
name: Get release metadata
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: Get version
id: get_version
run: echo "version=dcutr-example-$(cargo read-manifest --manifest-path examples/dcutr/Cargo.toml | 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: Build and release
runs-on: ubuntu-latest
needs: metadata
if: needs.metadata.outputs.release_exists == 'false'
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: Build for Intel Linux
run: cargo build -p dcutr-example --release --target=x86_64-unknown-linux-gnu

- name: Build for Aarch Linux
run: cross build -p dcutr-example --release --target=aarch64-unknown-linux-gnu

- name: Create artifacts directory
run: |
mkdir -p artifacts
cp target/x86_64-unknown-linux-gnu/release/dcutr-example artifacts/dcutr-example-x86_64-unknown-linux
cp target/aarch64-unknown-linux-gnu/release/dcutr-example artifacts/dcutr-example-aarch64-unknown-linux
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.metadata.outputs.version }}
files: |
artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95 changes: 88 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[workspace]
members = [".", "examples/dcutr"]

[package]
name = "relay-server"
version = "0.2.0"
Expand Down
38 changes: 38 additions & 0 deletions examples/dcutr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "dcutr-example"
version = "0.1.0"
authors = ["Calimero Limited <[email protected]>"]
edition = "2021"
repository = "https://github.com/calimero-network/relay-server"
license = "MIT OR Apache-2.0"

[dependencies]
camino = "1.1.6"
clap = { version = "4.5.4", features = ["derive", "env"] }
eyre = "0.6.12"
libp2p = { version = "0.53.2", features = [
"dcutr",
"dns",
"identify",
"macros",
"noise",
"ping",
"quic",
"relay",
"tokio",
"tcp",
"tls",
"yamux",
] }
multiaddr = "0.18.1"
serde = "1.0.196"
serde_json = "1.0.113"
tokio = { version = "1.35.1", features = [
"io-std",
"macros",
"rt",
"rt-multi-thread",
] }
toml = "0.8.9"
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
Loading

0 comments on commit f131308

Please sign in to comment.