Skip to content

Commit d942be3

Browse files
committed
feat(ci): add docker publish job
1 parent bd5f8aa commit d942be3

2 files changed

Lines changed: 145 additions & 1 deletion

File tree

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Publish Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- "*"
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: docker-publish-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
resolve:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
should_publish: ${{ steps.publish.outputs.should_publish }}
20+
image_tag: ${{ steps.publish.outputs.image_tag }}
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Resolve publish tag
28+
id: publish
29+
shell: bash
30+
run: |
31+
set -euo pipefail
32+
33+
should_publish=false
34+
image_tag=""
35+
36+
if [[ "${GITHUB_REF_TYPE}" == "branch" && "${GITHUB_REF_NAME}" == "master" ]]; then
37+
should_publish=true
38+
image_tag="latest"
39+
elif [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
40+
git fetch --no-tags origin master
41+
if git merge-base --is-ancestor "${GITHUB_SHA}" "origin/master"; then
42+
should_publish=true
43+
image_tag="${GITHUB_REF_NAME}"
44+
fi
45+
fi
46+
47+
echo "should_publish=${should_publish}" >> "${GITHUB_OUTPUT}"
48+
echo "image_tag=${image_tag}" >> "${GITHUB_OUTPUT}"
49+
50+
build:
51+
needs: resolve
52+
if: needs.resolve.outputs.should_publish == 'true'
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
include:
57+
- arch: amd64
58+
platform: linux/amd64
59+
runner: ubuntu-latest
60+
- arch: arm64
61+
platform: linux/arm64
62+
runner: ubuntu-24.04-arm
63+
runs-on: ${{ matrix.runner }}
64+
permissions:
65+
contents: read
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v4
69+
70+
- name: Set up Docker Buildx
71+
uses: docker/setup-buildx-action@v3
72+
73+
- name: Log in to Docker Hub
74+
uses: docker/login-action@v3
75+
with:
76+
username: blockstream
77+
password: ${{ secrets.DOCKERHUB_TOKEN }}
78+
79+
- name: Build and push ${{ matrix.arch }}
80+
uses: docker/build-push-action@v6
81+
with:
82+
context: .
83+
file: ./Dockerfile
84+
platforms: ${{ matrix.platform }}
85+
push: true
86+
tags: blockstream/waterfalls:${{ needs.resolve.outputs.image_tag }}-${{ matrix.arch }}
87+
cache-from: type=gha,scope=waterfalls-${{ matrix.arch }}
88+
cache-to: type=gha,mode=max,scope=waterfalls-${{ matrix.arch }}
89+
90+
manifest:
91+
needs:
92+
- resolve
93+
- build
94+
if: needs.resolve.outputs.should_publish == 'true'
95+
runs-on: ubuntu-latest
96+
permissions:
97+
contents: read
98+
steps:
99+
- name: Set up Docker Buildx
100+
uses: docker/setup-buildx-action@v3
101+
102+
- name: Log in to Docker Hub
103+
uses: docker/login-action@v3
104+
with:
105+
username: blockstream
106+
password: ${{ secrets.DOCKERHUB_TOKEN }}
107+
108+
- name: Create multi-arch manifest
109+
shell: bash
110+
run: |
111+
set -euo pipefail
112+
docker buildx imagetools create \
113+
-t blockstream/waterfalls:${{ needs.resolve.outputs.image_tag }} \
114+
blockstream/waterfalls:${{ needs.resolve.outputs.image_tag }}-amd64 \
115+
blockstream/waterfalls:${{ needs.resolve.outputs.image_tag }}-arm64
116+
117+
- name: Inspect manifest
118+
run: docker buildx imagetools inspect blockstream/waterfalls:${{ needs.resolve.outputs.image_tag }}

AGENTS.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ No `rustfmt.toml` or `clippy.toml` — default settings are used.
6666
### Imports
6767

6868
Grouped in this order (separated by blank lines when practical):
69+
6970
1. `std::` — standard library
7071
2. External crates — `anyhow`, `elements`, `hyper`, `serde`, `tokio`, etc.
7172
3. `crate::` / `super::` — internal modules
@@ -128,13 +129,38 @@ tests/integration.rs # Integration tests
128129
benches/benches.rs # Criterion benchmarks
129130
```
130131

131-
## CI (`.github/workflows/rust.yml`)
132+
## CI
133+
134+
### Rust checks (`.github/workflows/rust.yml`)
132135

133136
Runs on push/PR to `master`:
137+
134138
- **tests**: downloads bitcoind 28.0 & elementsd 23.2.4, runs `cargo test` and `cargo test -- --ignored`
135139
- **checks**: `cargo check` with various feature combinations
136140
- **nix**: `nix build .` with cachix
137141

142+
### Docker publish (`.github/workflows/docker-publish.yml`)
143+
144+
Runs on push to `master`, tag creation, and manual dispatch:
145+
146+
- Push to `master` publishes `blockstream/waterfalls:latest`
147+
- Tag push publishes `blockstream/waterfalls:<git-tag>` only when the tagged commit is on `master`
148+
149+
The workflow builds native images on:
150+
151+
- `ubuntu-latest` for `linux/amd64`
152+
- `ubuntu-24.04-arm` for `linux/arm64`
153+
154+
Then it creates a multi-arch manifest tag from per-arch tags:
155+
156+
- `blockstream/waterfalls:<final-tag>-amd64`
157+
- `blockstream/waterfalls:<final-tag>-arm64`
158+
- `blockstream/waterfalls:<final-tag>` (manifest list with both architectures)
159+
160+
Required GitHub repository secret:
161+
162+
- `DOCKERHUB_TOKEN`
163+
138164
## Cursor Rules
139165

140166
From `.cursor/rules/my-custom-rule.mdc` (always applied):

0 commit comments

Comments
 (0)