66 - " v*"
77 workflow_dispatch :
88 inputs :
9- custom_tag :
9+ docker_tag :
1010 description : " Custom Docker image tag (e.g., v0.3.7-dev)"
1111 required : true
12+ branch :
13+ description : " Branch to use for SDK build (optional if tag is used)"
14+ required : false
1215 push_latest :
1316 description : " Also tag as latest"
1417 required : false
1922 REGISTRY : ghcr.io
2023 IMAGE_NAME : ${{ github.repository_owner }}/fluentbase-build
2124 RUST_TOOLCHAIN : 1.88
22- BINARYEN_VERSION : 120
23- WABT_VERSION : 1.0.36
24- WABT_OS : ubuntu-20.04
25- PLATFORM : linux/amd64
2625
2726jobs :
2827 build :
29- runs-on : ubuntu-amd64-8core
28+ runs-on : ubuntu-latest
29+ timeout-minutes : 45
3030 permissions :
3131 contents : read
3232 packages : write
3333
3434 steps :
3535 - name : Checkout repository
3636 uses : actions/checkout@v5
37- with :
38- submodules : recursive
3937
4038 - name : Set up Docker Buildx
4139 uses : docker/setup-buildx-action@v3
@@ -47,80 +45,96 @@ jobs:
4745 username : ${{ github.actor }}
4846 password : ${{ secrets.GITHUB_TOKEN }}
4947
50- - name : Extract metadata (tag, tags, version)
48+ - name : Extract metadata
5149 id : meta
50+ shell : bash
5251 run : |
53- SHA_SHORT=$(echo ${{ github.sha }} | cut -c1-7)
52+ set -euo pipefail
5453
55- # Manual workflow dispatch with custom tag
56- if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
57- VERSION="${{ inputs.custom_tag }}"
58- TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}"
59- if [[ "${{ inputs.push_latest }}" == "true" ]]; then
60- TAGS="${TAGS},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
61- fi
62- echo "🚀 Manual build triggered with custom tag: ${VERSION}"
63- # Automatic push with git tag
64- elif [[ "${{ github.ref_type }}" == "tag" ]]; then
65- VERSION="${GITHUB_REF#refs/tags/}"
66- TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
67- echo "🏷️ Git tag build: ${VERSION}"
68- # Push to branch (development)
54+ SHA_SHORT=$(echo "${{ github.sha }}" | cut -c1-7)
55+ IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
56+ EVENT="${{ github.event_name }}"
57+ REF_TYPE="${{ github.ref_type }}"
58+ REF_NAME="${{ github.ref_name }}"
59+
60+ # --- Determine version and SDK args ---
61+ if [[ "$EVENT" == "workflow_dispatch" ]]; then
62+ VERSION="${{ inputs.docker_tag }}"
63+ if [[ -n "${{ inputs.branch }}" ]]; then
64+ SDK_VERSION_BRANCH="${{ inputs.branch }}"
65+ SDK_VERSION_TAG=""
66+ else
67+ SDK_VERSION_BRANCH=""
68+ SDK_VERSION_TAG="${VERSION}"
69+ fi
70+ elif [[ "$REF_TYPE" == "tag" ]]; then
71+ VERSION="$REF_NAME"
72+ SDK_VERSION_BRANCH=""
73+ SDK_VERSION_TAG="${VERSION}"
6974 else
70- VERSION="dev-$SHA_SHORT"
71- TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$VERSION"
72- echo "🔧 Development build: ${VERSION}"
75+ VERSION="dev-${SHA_SHORT}"
76+ SDK_VERSION_BRANCH="${REF_NAME}"
77+ SDK_VERSION_TAG=""
78+ fi
79+
80+ TAGS="${IMAGE}:${VERSION}"
81+ if [[ ("$EVENT" == "workflow_dispatch" && "${{ inputs.push_latest }}" == "true") || "$REF_TYPE" == "tag" ]]; then
82+ TAGS+=",${IMAGE}:latest"
7383 fi
7484
75- echo "tags=${TAGS}" >> $GITHUB_OUTPUT
76- echo "sdk_version=${VERSION}" >> $GITHUB_OUTPUT
77- echo "Final tags: ${TAGS}"
85+ {
86+ echo "tags=${TAGS}"
87+ echo "version=${VERSION}"
88+ echo "sdk_version_branch=${SDK_VERSION_BRANCH}"
89+ echo "sdk_version_tag=${SDK_VERSION_TAG}"
90+ } >> "$GITHUB_OUTPUT"
91+
92+ echo "Resolved metadata:"
93+ echo " VERSION=${VERSION}"
94+ echo " BRANCH=${SDK_VERSION_BRANCH}"
95+ echo " TAG=${SDK_VERSION_TAG}"
96+ echo " TAGS=${TAGS}"
7897
79- - name : Build and push Docker image
98+ - name : Build and push
8099 uses : docker/build-push-action@v6
81100 with :
82101 context : ./
83102 file : ./Dockerfile
84- platforms : ${{ env.PLATFORM }}
103+ platforms : linux/amd64
85104 push : true
86105 tags : ${{ steps.meta.outputs.tags }}
87- cache-from : type=gha
88- cache-to : type=gha,mode=max
89- build-args : |
90- RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
91- PLATFORM=${{ env.PLATFORM }}
92- SDK_VERSION=${{ steps.meta.outputs.sdk_version }}
93- BINARYEN_VERSION=${{ env.BINARYEN_VERSION }}
94- WABT_VERSION=${{ env.WABT_VERSION }}
95- WABT_OS=${{ env.WABT_OS }}
96106 labels : |
97107 org.opencontainers.image.source=${{ github.event.repository.html_url }}
108+ org.opencontainers.image.version=${{ steps.meta.outputs.sdk_version }}
98109 org.opencontainers.image.revision=${{ github.sha }}
99- org.opencontainers.image.ref.name=${{ github.ref }}
100110 org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
101- org.opencontainers.image.title=Fluent Build Environment
102- org.opencontainers.image.description=Docker image for building Fluent smart contracts
103- rust.toolchain=${{ env.RUST_TOOLCHAIN }}
104- fluentbase.sdk.version=${{ steps.meta.outputs.sdk_version }}
111+ org.opencontainers.image.title=Fluent Reproducible Build Environment
112+ org.opencontainers.image.description=Pre-warmed Docker image for reproducible cross-platform builds of Fluent smart contracts
113+ xyz.fluent.sdk.version=${{ steps.meta.outputs.sdk_version }}
114+ xyz.fluent.rust.toolchain=${{ env.RUST_TOOLCHAIN }}
115+ build-args : |
116+ RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
117+ SDK_VERSION_BRANCH=${{ steps.meta.outputs.sdk_version_branch }}
118+ SDK_VERSION_TAG=${{ steps.meta.outputs.sdk_version_tag }}
119+ no-cache : true
120+
121+ - name : Inspect image
122+ run : |
123+ docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
105124
106125 - name : Print summary
107126 run : |
108- echo "### Docker Image Published 🚀 " >> $GITHUB_STEP_SUMMARY
127+ echo "### 🚀 Docker Image Published" >> $GITHUB_STEP_SUMMARY
109128 echo "" >> $GITHUB_STEP_SUMMARY
110- echo "**Build Type:** \`${{ github.event_name }}\`" >> $GITHUB_STEP_SUMMARY
111- echo "**Rust Toolchain:** \`${{ env.RUST_TOOLCHAIN }}\`" >> $GITHUB_STEP_SUMMARY
112- echo "**SDK Version:** \`${{ steps.meta.outputs.sdk_version }}\`" >> $GITHUB_STEP_SUMMARY
113- if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
114- echo "**Custom Tag:** \`${{ inputs.custom_tag }}\`" >> $GITHUB_STEP_SUMMARY
115- echo "**Push Latest:** \`${{ inputs.push_latest }}\`" >> $GITHUB_STEP_SUMMARY
116- fi
129+ echo "| Property | Value |" >> $GITHUB_STEP_SUMMARY
130+ echo "|----------|-------|" >> $GITHUB_STEP_SUMMARY
131+ echo "| **Platform** | \`linux/amd64\` |" >> $GITHUB_STEP_SUMMARY
132+ echo "| **Rust** | \`${{ env.RUST_TOOLCHAIN }}\` |" >> $GITHUB_STEP_SUMMARY
133+ echo "| **SDK Version** | \`v${{ steps.meta.outputs.sdk_version }}\` |" >> $GITHUB_STEP_SUMMARY
134+ echo "| **Commit** | \`${{ github.sha }}\` |" >> $GITHUB_STEP_SUMMARY
117135 echo "" >> $GITHUB_STEP_SUMMARY
118- echo "**Tags :**" >> $GITHUB_STEP_SUMMARY
119- IFS=',' read -ra ADDR <<< "${{ steps.meta.outputs.tags }}"
120- for tag in "${ADDR [@]}"; do
121- echo "- \`${tag}\`" >> $GITHUB_STEP_SUMMARY
136+ echo "**Available tags :**" >> $GITHUB_STEP_SUMMARY
137+ IFS=',' read -ra TAG_ARRAY <<< "${{ steps.meta.outputs.tags }}"
138+ for tag in "${TAG_ARRAY [@]}"; do
139+ echo "- \`docker pull ${tag}\`" >> $GITHUB_STEP_SUMMARY
122140 done
123- echo "" >> $GITHUB_STEP_SUMMARY
124- echo "**Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
125- echo "**Branch/Tag:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
126- echo "**Actor:** @${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
0 commit comments