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