Skip to content

Commit 7a63870

Browse files
authored
Merge pull request #21 from p2p-org/feat/sei-builds
feat: build sei allowing standard tag and url encoded branch / commit…
2 parents 51e78b5 + 26d2cb9 commit 7a63870

2 files changed

Lines changed: 146 additions & 8 deletions

File tree

.github/workflows/sei.yaml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Sei workflow usage:
2+
# - Release build tag:
3+
# seid-v6.3.2
4+
#
5+
# - Commit-pinned build tag (with branch metadata):
6+
# seid-ref-<url-encoded-branch>--<commit>
7+
# Example:
8+
# seid-ref-release%2F6.3--abc1234def56
9+
# Commit should be at least 12 hex chars (up to full 40-char SHA).
10+
#
11+
# - URL-encode a branch name:
12+
# python3 -c 'import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1], safe=""))' "release/6.3"
13+
# Optional (if jq is installed):
14+
# printf '%s' "release/6.3" | jq -sRr @uri
15+
#
16+
# - Manual run (workflow_dispatch):
17+
# Set `sei_ref` to any valid Sei ref (tag/branch/commit). Default is v6.3.2.
18+
# `sei_branch` is optional metadata for commit-based builds.
19+
20+
name: Build and Push sei Docker Image
21+
22+
on:
23+
push:
24+
tags:
25+
- "seid-v*"
26+
- "seid-ref-*"
27+
workflow_dispatch:
28+
inputs:
29+
sei_ref:
30+
description: "Sei ref to build (tag, branch, or commit)"
31+
required: false
32+
default: "v6.3.2"
33+
sei_branch:
34+
description: "Optional branch metadata (for commit builds)"
35+
required: false
36+
37+
env:
38+
REGISTRY: ghcr.io
39+
IMAGE_NAME: ${{ github.repository }}
40+
INFRA_TOOLKIT: v0.1.6
41+
42+
jobs:
43+
build-and-push-sei:
44+
runs-on: ubuntu-latest
45+
permissions:
46+
contents: read
47+
packages: write
48+
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v2
52+
53+
- name: Set up Go
54+
uses: actions/setup-go@v3
55+
with:
56+
go-version: '1.24.1'
57+
58+
- name: Log in to the Container registry
59+
uses: docker/login-action@v1
60+
with:
61+
registry: ${{ env.REGISTRY }}
62+
username: ${{ github.actor }}
63+
password: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Build Heighliner binary
66+
run: |
67+
go build -o heighliner
68+
69+
- name: Resolve Sei ref and image tag
70+
id: resolve_ref
71+
run: |
72+
set -euo pipefail
73+
74+
DEFAULT_SEI_REF="v6.3.2"
75+
SOURCE_KIND=""
76+
SEI_GIT_REF=""
77+
IMAGE_VERSION=""
78+
BRANCH_META=""
79+
80+
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
81+
SEI_GIT_REF="${{ github.event.inputs.sei_ref }}"
82+
BRANCH_META="${{ github.event.inputs.sei_branch }}"
83+
if [[ -z "${SEI_GIT_REF}" ]]; then
84+
SEI_GIT_REF="${DEFAULT_SEI_REF}"
85+
fi
86+
SOURCE_KIND="manual"
87+
else
88+
TAG_NAME="${GITHUB_REF#refs/tags/}"
89+
90+
if [[ "${TAG_NAME}" =~ ^seid-v(.+)$ ]]; then
91+
SEI_GIT_REF="v${BASH_REMATCH[1]}"
92+
BRANCH_META="release"
93+
SOURCE_KIND="release"
94+
elif [[ "${TAG_NAME}" =~ ^seid-ref-(.+)--([0-9a-fA-F]{12,40})$ ]]; then
95+
BRANCH_ENCODED="${BASH_REMATCH[1]}"
96+
SEI_GIT_REF="${BASH_REMATCH[2]}"
97+
BRANCH_META="$(python3 -c 'import sys, urllib.parse; print(urllib.parse.unquote(sys.argv[1]))' "${BRANCH_ENCODED}")"
98+
SOURCE_KIND="ref"
99+
else
100+
echo "Unsupported tag '${TAG_NAME}'." >&2
101+
echo "Expected 'seid-v<version>' or 'seid-ref-<url-encoded-branch>--<commit>'." >&2
102+
echo "For seid-ref tags, commit must be 12-40 hex characters." >&2
103+
exit 1
104+
fi
105+
fi
106+
107+
SAFE_REF="$(echo "${SEI_GIT_REF}" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9._-]+/-/g; s/^-+//; s/-+$//; s/-+/-/g')"
108+
if [[ -z "${SAFE_REF}" ]]; then
109+
echo "Unable to create safe image tag from SEI_GIT_REF='${SEI_GIT_REF}'." >&2
110+
exit 1
111+
fi
112+
113+
if [[ "${SOURCE_KIND}" == "ref" ]]; then
114+
IMAGE_VERSION="ref-${SAFE_REF}"
115+
else
116+
IMAGE_VERSION="${SAFE_REF}"
117+
fi
118+
119+
echo "SEI_GIT_REF=${SEI_GIT_REF}" >> "$GITHUB_ENV"
120+
echo "IMAGE_VERSION=${IMAGE_VERSION}" >> "$GITHUB_ENV"
121+
echo "SOURCE_KIND=${SOURCE_KIND}" >> "$GITHUB_ENV"
122+
echo "SEI_BRANCH_META=${BRANCH_META}" >> "$GITHUB_ENV"
123+
echo "sei_git_ref=${SEI_GIT_REF}" >> "$GITHUB_OUTPUT"
124+
echo "image_version=${IMAGE_VERSION}" >> "$GITHUB_OUTPUT"
125+
echo "source_kind=${SOURCE_KIND}" >> "$GITHUB_OUTPUT"
126+
echo "sei_branch_meta=${BRANCH_META}" >> "$GITHUB_OUTPUT"
127+
echo "Resolved SEI_GIT_REF=${SEI_GIT_REF}, IMAGE_VERSION=${IMAGE_VERSION}, SOURCE_KIND=${SOURCE_KIND}, SEI_BRANCH_META=${BRANCH_META}"
128+
129+
- name: Manually pull the base Docker image
130+
run: |
131+
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
132+
docker pull ghcr.io/p2p-org/cosmos-heighliner:infra-toolkit-${{ env.INFRA_TOOLKIT }}
133+
134+
- name: Build and push sei Docker image
135+
run: |
136+
./heighliner build -c sei --git-ref ${{ steps.resolve_ref.outputs.sei_git_ref }}
137+
138+
- name: Tag and push Docker image
139+
run: |
140+
docker tag sei:${{ steps.resolve_ref.outputs.sei_git_ref }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sei-${{ steps.resolve_ref.outputs.image_version }}
141+
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sei-${{ steps.resolve_ref.outputs.image_version }}

chains/sei.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@
33
github-organization: sei-protocol
44
github-repo: sei-chain
55
dockerfile: cargo
6-
pre-build: |
7-
wget https://github.com/sei-protocol/sei-wasmvm/archive/refs/tags/v1.5.4-sei.0.0.1.zip
8-
unzip v1.5.4-sei.0.0.1.zip
9-
cd sei-wasmvm-1.5.4-sei.0.0.1
10-
make build-rust
11-
cp internal/api/libwasmvm.x86_64.so /usr/lib/libwasmvm.x86_64.so
126
build-target: |
13-
make install install-price-feeder
7+
# Keep parity with sei-builds-seid expectations by building full artifacts.
8+
make build install install-price-feeder
149
binaries:
1510
- /root/go/bin/seid
1611
- /root/go/bin/price-feeder
1712
libraries:
18-
- /usr/lib/libwasmvm.x86_64.so
13+
# Keep parity with sei-builds-seid Makefile extraction logic.
14+
- /build/sei-chain/sei-wasmvm/internal/api/libwasmvm*.so
15+
- /build/sei-chain/sei-wasmd/x/wasm/artifacts/v*/api/libwasmvm*.so
1916
platforms:
2017
- linux/amd64

0 commit comments

Comments
 (0)