Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/publish-node-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,37 @@ jobs:
type=ref,event=tag
type=semver,pattern={{version}}

- name: Read the commit time
id: commit
run: echo "time=$(git log -1 --format=%cI)" >> "$GITHUB_OUTPUT"

# Build and load the image first, so a binary that reports the wrong version is never
# pushed. The push step below reuses this build's cache.
- name: Build image for the version check (linux/amd64)
uses: docker/build-push-action@v5
with:
context: .
file: deployments/Dockerfile
load: true
platforms: linux/amd64
tags: tn-node:version-check
build-args: |
TN_VERSION=${{ steps.meta.outputs.version }}
TN_COMMIT=${{ github.sha }}
TN_BUILD_TIME=${{ steps.commit.outputs.time }}
cache-from: type=gha

- name: Check that kwild reports the image version
env:
EXPECTED: ${{ steps.meta.outputs.version }}
run: |
got=$(docker run --rm --entrypoint /app/kwild tn-node:version-check version --output json | jq -r '.result.version')
if [ "$got" != "$EXPECTED" ]; then
echo "::error::kwild version prints '$got', but the image version is '$EXPECTED'"
exit 1
fi
echo "kwild reports $EXPECTED"

- name: Build and push image (linux/amd64)
uses: docker/build-push-action@v5
with:
Expand All @@ -59,6 +90,10 @@ jobs:
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TN_VERSION=${{ steps.meta.outputs.version }}
TN_COMMIT=${{ github.sha }}
TN_BUILD_TIME=${{ steps.commit.outputs.time }}
cache-from: type=gha
cache-to: type=gha,mode=max

Expand Down
33 changes: 27 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,55 @@ jobs:
VERSION=${GITHUB_REF#refs/tags/}
VERSION=${VERSION#v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
# stamp the release, its commit and the commit time into kwild, as task build does
PKG=github.com/trufnetwork/node/cmd/version
BUILD_TIME=$(git log -1 --format=%cI)
echo "LDFLAGS=-X $PKG.TNVersion=$VERSION -X $PKG.TNCommit=$GITHUB_SHA -X $PKG.TNBuildTime=$BUILD_TIME" >> $GITHUB_ENV

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
check-latest: true
go-version-file: go.mod

- name: Build for Darwin AMD64
run: |
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o ./.build/kwild ./cmd/kwild/main.go
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -o ./.build/kwild ./cmd/kwild/main.go
tar -czvf ./.build/tn_${{ env.VERSION }}_darwin_amd64.tar.gz -C ./.build kwild
rm -rf ./.build/kwild

- name: Build for Darwin ARM64
run: |
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -o ./.build/kwild ./cmd/kwild/main.go
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -o ./.build/kwild ./cmd/kwild/main.go
tar -czvf ./.build/tn_${{ env.VERSION }}_darwin_arm64.tar.gz -C ./.build kwild
rm -rf ./.build/kwild

- name: Build for Linux AMD64
run: |
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ./.build/kwild ./cmd/kwild/main.go
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -o ./.build/kwild ./cmd/kwild/main.go

# The runner can run only this binary; the other three take the same LDFLAGS.
- name: Check that kwild reports the release version
run: |
got=$(./.build/kwild version --output json | jq -r '.result.version')
if [ "$got" != "$VERSION" ]; then
echo "::error::kwild version prints '$got', but the release is '$VERSION'"
exit 1
fi
got=$(./.build/kwild --version)
if [ "$got" != "kwild version $VERSION" ]; then
echo "::error::kwild --version prints '$got', but the release is '$VERSION'"
exit 1
fi
echo "kwild reports $VERSION"

- name: Package Linux AMD64
run: |
tar -czvf ./.build/tn_${{ env.VERSION }}_linux_amd64.tar.gz -C ./.build kwild
rm -rf ./.build/kwild

- name: Build for Linux ARM64
run: |
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o ./.build/kwild ./cmd/kwild/main.go
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -o ./.build/kwild ./cmd/kwild/main.go
tar -czvf ./.build/tn_${{ env.VERSION }}_linux_arm64.tar.gz -C ./.build kwild
rm -rf ./.build/kwild

Expand Down
11 changes: 11 additions & 0 deletions cmd/version/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ var (
TNBuildTime string // -X github.com/trufnetwork/node/cmd/version.TNBuildTime=...
)

// kwild --version, the "Starting kwild version" log line and kwil_ver in the
// RPC version methods (user.version and the others) read kwil-db's
// KwilVersion. When a build sets TNVersion, KwilVersion takes the same value,
// so they all report the TN release. The health endpoints keep their API
// versions.
func init() {
if TNVersion != "" {
kwilVersion.KwilVersion = TNVersion
}
}

// getVersion returns the TN version if set, otherwise falls back to kwil-db version
func getVersion() string {
if TNVersion != "" {
Expand Down
13 changes: 11 additions & 2 deletions deployments/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,21 @@ COPY internal/ ./internal/
COPY extensions/ ./extensions/
COPY deployments/tn-entrypoint.sh ./deployments/tn-entrypoint.sh

# todo: incorporate task build process, otherwise images will lack information about the build
# The TN release, commit and commit time that kwild version, kwild --version, the
# startup log and user.version report. The image workflow passes them; a local
# build without them reports 0.0.0-dev.
ARG TN_VERSION=0.0.0-dev
ARG TN_COMMIT=unknown
ARG TN_BUILD_TIME=

# Use build cache mounts for faster rebuilds
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
pkg=github.com/trufnetwork/node/cmd/version && \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
go build -o /app/.build/kwild /app/cmd/kwild/main.go
go build \
-ldflags "-X ${pkg}.TNVersion=${TN_VERSION} -X ${pkg}.TNCommit=${TN_COMMIT} -X ${pkg}.TNBuildTime=${TN_BUILD_TIME}" \
-o /app/.build/kwild /app/cmd/kwild/main.go

# Pin to alpine3.21 to match the final runtime stage below: the floating
# `postgres:16-alpine` tag has moved to Alpine 3.24, which dropped the clang19/llvm19
Expand Down
4 changes: 3 additions & 1 deletion docs/node-operator-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -958,10 +958,12 @@ Sometimes you may need to reset your node to sync from a specific point or recov
sudo mv .build/kwild /usr/local/bin/kwild
sudo chmod +x /usr/local/bin/kwild

# Verify version
# Verify version: "Version:" shows the TN release, for example 2.6.9
kwild version
```

A binary that prints `Version: 0.10.1` (kwil-db's version) was built before TN releases carried their own version. See [Check the version](node-upgrade-guide.md#3-install-the-latest-kwild-binary) in the upgrade guide for what the output shows and how to read the release of a node that runs in Docker.

6. **Restore node identity and custom configuration** *(optional)*:

> **Note**: Skip this step if you want to start with a completely fresh node identity and default configuration. Only restore if you need to preserve your existing validator status or custom settings.
Expand Down
17 changes: 17 additions & 0 deletions docs/node-upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ If you manage `kwild` with another init system or inside Docker Compose, use the
```bash
kwild version
```
`Version` is the TN release the binary was built from, and `Git commit` is the first 9 characters of its commit. A `v2.6.9` release binary prints, for example:
```text
Version: 2.6.9
Git commit: <first 9 characters of the release commit>
Built: <commit time> (commit time)
Go version: go1.25.3
OS/Arch: linux/amd64
```
`kwild --version` prints the same release (`kwild version 2.6.9`), and `kwild version --output json | jq -r .result.version` prints only `2.6.9`. A binary built with `task build` prints the `git describe` version of your clone instead, such as `2.6.8-4-g9e008683` for a clone 4 commits past `v2.6.8`.

A binary that prints `0.10.1` (kwil-db's version) was built before TN releases carried their own version, as the v2.6.8 release was. Read its release from the release page or tarball you downloaded it from.

If your node runs in Docker, read the release from the image label of the running container:
```bash
docker inspect --format '{{ index .Config.Labels "org.opencontainers.image.version" }}' <container>
```
For an image that carries the TN version, `docker exec <container> /app/kwild version` prints the same release; an older image prints `0.10.1` there.

---

Expand Down
Loading