-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (112 loc) · 4.65 KB
/
Copy pathrelease.yml
File metadata and controls
127 lines (112 loc) · 4.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Build and release
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=$(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/boot-node/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: Install cross
run: cargo install cross --version 0.2.5
- name: Build for Intel Linux
run: cargo build --release --target=x86_64-unknown-linux-gnu
- name: Build for Aarch Linux
run: cross build --release --target=aarch64-unknown-linux-gnu
- name: Create artifacts directory
run: |
mkdir -p artifacts
cp target/x86_64-unknown-linux-gnu/release/boot-node artifacts/boot-node-x86_64-unknown-linux
cp target/aarch64-unknown-linux-gnu/release/boot-node artifacts/boot-node-aarch64-unknown-linux
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.metadata.outputs.version }}
files: |
README.md
artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# The Docker image bundles the release binaries (built above)
# into a debian-slim base and pushes a multi-arch manifest to
# GHCR. Downstream consumers (merobox#256+) pull this image
# at runtime so they don't have to keep a Dockerfile bundled
# in their own tree.
#
# Layout for buildx context: COPY in the Dockerfile expects
# binaries under `artifacts/<docker-arch>/boot-node`, so we
# restage the GitHub-release-named binaries into the
# docker-arch directory layout before invoking buildx.
- name: Stage binaries for Docker build
run: |
mkdir -p artifacts/amd64 artifacts/arm64
cp artifacts/boot-node-x86_64-unknown-linux artifacts/amd64/boot-node
cp artifacts/boot-node-aarch64-unknown-linux artifacts/arm64/boot-node
chmod +x artifacts/amd64/boot-node artifacts/arm64/boot-node
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Tags published per release:
# * <version> (e.g. 0.7.0) — immutable, pinned by consumers
# * latest — current published release
# * edge — also tracks latest, matches the
# naming convention merod uses
# (`ghcr.io/calimero-network/merod:edge`)
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/calimero-network/boot-node:${{ needs.metadata.outputs.version }}
ghcr.io/calimero-network/boot-node:latest
ghcr.io/calimero-network/boot-node:edge
labels: |
org.opencontainers.image.source=https://github.com/calimero-network/boot-node
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ needs.metadata.outputs.version }}
org.opencontainers.image.licenses=Apache-2.0