feat: implement dcutr example and release automation #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and release dcutr example | |
on: | |
push: | |
branches: | |
- master | |
- feat/dcutr-example | |
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 | |
working-directory: examples/dcutr | |
run: echo "version=dcutr-example-$(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: 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: Install cross | |
working-directory: examples/dcutr | |
run: cargo install cross --version 0.2.5 | |
- name: Build for Intel Linux | |
working-directory: examples/dcutr | |
run: cargo build --release --target=x86_64-unknown-linux-gnu | |
- name: Build for Aarch Linux | |
working-directory: examples/dcutr | |
run: cross build --release --target=aarch64-unknown-linux-gnu | |
- name: Create artifacts directory | |
working-directory: examples/dcutr | |
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: | | |
examples/dcutr/artifacts/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |