From 01936b346098e4c603f035622dfd24846ac5cb52 Mon Sep 17 00:00:00 2001
From: Serban Iorga <serban@parity.io>
Date: Wed, 30 Oct 2024 18:20:09 +0200
Subject: [PATCH] Publish `polkadot-omni-node` binary (#6057)

Closes https://github.com/paritytech/polkadot-sdk/issues/5566

Publish the `polkadot-omni-node` binary

This is a best effort. I'm not very familiar with the release /
publishing process and also not sure how to test this.
@paritytech/release-engineering can you take a look on this PR please ?

---------

Co-authored-by: EgorPopelyaev <egor@parity.io>
---
 .../release-30_publish_release_draft.yml      |  6 +--
 .../workflows/release-50_publish-docker.yml   | 41 ++++++++++---------
 .../polkadot-omni-node/build-injected.sh      | 14 +++++++
 3 files changed, 38 insertions(+), 23 deletions(-)
 create mode 100755 docker/scripts/polkadot-omni-node/build-injected.sh

diff --git a/.github/workflows/release-30_publish_release_draft.yml b/.github/workflows/release-30_publish_release_draft.yml
index 2a5d92ed167..73d1aeaa400 100644
--- a/.github/workflows/release-30_publish_release_draft.yml
+++ b/.github/workflows/release-30_publish_release_draft.yml
@@ -26,7 +26,7 @@ jobs:
   build-runtimes:
     uses: "./.github/workflows/release-srtool.yml"
     with:
-       excluded_runtimes: "asset-hub-rococo bridge-hub-rococo contracts-rococo coretime-rococo people-rococo rococo rococo-parachain substrate-test bp cumulus-test kitchensink minimal-template parachain-template penpal polkadot-test seedling shell frame-try sp solochain-template"
+       excluded_runtimes: "asset-hub-rococo bridge-hub-rococo contracts-rococo coretime-rococo people-rococo rococo rococo-parachain substrate-test bp cumulus-test kitchensink minimal-template parachain-template penpal polkadot-test seedling shell frame-try sp solochain-template polkadot-sdk-docs-first"
        build_opts: "--features on-chain-release-build"
 
   build-binaries:
@@ -34,7 +34,7 @@ jobs:
     strategy:
       matrix:
         # Tuples of [package, binary-name]
-        binary: [ [frame-omni-bencher, frame-omni-bencher], [staging-chain-spec-builder, chain-spec-builder] ]
+        binary: [ [frame-omni-bencher, frame-omni-bencher], [staging-chain-spec-builder, chain-spec-builder], [polkadot-omni-node, polkadot-omni-node] ]
     steps:
       - name: Checkout sources
         uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.0.0
@@ -161,7 +161,7 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        binary: [frame-omni-bencher, chain-spec-builder]
+        binary: [frame-omni-bencher, chain-spec-builder, polkadot-omni-node]
 
     steps:
       - name: Download artifacts
diff --git a/.github/workflows/release-50_publish-docker.yml b/.github/workflows/release-50_publish-docker.yml
index 6e0e8f20aa5..211fa000f8f 100644
--- a/.github/workflows/release-50_publish-docker.yml
+++ b/.github/workflows/release-50_publish-docker.yml
@@ -26,6 +26,7 @@ on:
         type: choice
         options:
           - polkadot
+          - polkadot-omni-node
           - polkadot-parachain
           - chain-spec-builder
 
@@ -80,9 +81,9 @@ jobs:
   validate-inputs:
     runs-on: ubuntu-latest
     outputs:
-        version: ${{ steps.validate_inputs.outputs.VERSION }}
-        release_id: ${{ steps.validate_inputs.outputs.RELEASE_ID }}
-        stable_tag: ${{ steps.validate_inputs.outputs.stable_tag }}
+      version: ${{ steps.validate_inputs.outputs.VERSION }}
+      release_id: ${{ steps.validate_inputs.outputs.RELEASE_ID }}
+      stable_tag: ${{ steps.validate_inputs.outputs.stable_tag }}
 
     steps:
       - name: Checkout sources
@@ -105,15 +106,15 @@ jobs:
           echo "stable_tag=${STABLE_TAG}" >> $GITHUB_OUTPUT
 
   fetch-artifacts: # this job will be triggered for the polkadot-parachain rc and release or polkadot rc image build
-    if: ${{ inputs.binary == 'polkadot-parachain' || inputs.binary == 'chain-spec-builder' || inputs.image_type == 'rc' }}
+    if: ${{ inputs.binary == 'polkadot-omni-node' || inputs.binary == 'polkadot-parachain' || inputs.binary == 'chain-spec-builder' || inputs.image_type == 'rc' }}
     runs-on: ubuntu-latest
-    needs: [validate-inputs]
+    needs: [ validate-inputs ]
 
     steps:
       - name: Checkout sources
         uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
 
-      #TODO: this step will be needed when automated triggering will work
+        #TODO: this step will be needed when automated triggering will work
         #this step runs only if the workflow is triggered automatically when new release is published
         # if: ${{ env.EVENT_NAME == 'release' && env.EVENT_ACTION != '' && env.EVENT_ACTION == 'published' }}
         # run: |
@@ -129,7 +130,7 @@ jobs:
 
       - name: Fetch rc artifacts or release artifacts from s3 based on version
         #this step runs only if the workflow is triggered manually
-        if: ${{ env.EVENT_NAME  == 'workflow_dispatch' && inputs.binary != 'chain-spec-builder'}}
+        if: ${{ env.EVENT_NAME  == 'workflow_dispatch' && inputs.binary != 'polkadot-omni-node' && inputs.binary != 'chain-spec-builder'}}
         run: |
           . ./.github/scripts/common/lib.sh
 
@@ -143,9 +144,9 @@ jobs:
             fetch_release_artifacts_from_s3 $BINARY
           fi
 
-      - name: Fetch chain-spec-builder rc artifacts or release artifacts based on release id
+      - name: Fetch polkadot-omni-node/chain-spec-builder rc artifacts or release artifacts based on release id
         #this step runs only if the workflow is triggered manually and only for chain-spec-builder
-        if: ${{ env.EVENT_NAME  == 'workflow_dispatch' && inputs.binary == 'chain-spec-builder' }}
+        if: ${{ env.EVENT_NAME  == 'workflow_dispatch' && (inputs.binary == 'polkadot-omni-node' || inputs.binary == 'chain-spec-builder') }}
         run: |
           . ./.github/scripts/common/lib.sh
 
@@ -159,9 +160,9 @@ jobs:
           path: release-artifacts/${{ env.BINARY }}/**/*
 
   build-container: # this job will be triggered for the polkadot-parachain rc and release or polkadot rc image build
-    if: ${{ inputs.binary == 'polkadot-parachain' || inputs.binary == 'chain-spec-builder' || inputs.image_type == 'rc' }}
+    if: ${{ inputs.binary == 'polkadot-omni-node' || inputs.binary == 'polkadot-parachain' || inputs.binary == 'chain-spec-builder' || inputs.image_type == 'rc' }}
     runs-on: ubuntu-latest
-    needs: [fetch-artifacts, validate-inputs]
+    needs: [ fetch-artifacts, validate-inputs ]
     environment: release
 
     steps:
@@ -231,8 +232,8 @@ jobs:
           echo "Building container for $BINARY"
           ./docker/scripts/polkadot/build-injected.sh $ARTIFACTS_FOLDER
 
-      - name: Build Injected Container image chain-spec-builder
-        if: ${{ env.BINARY == 'chain-spec-builder' }}
+      - name: Build Injected Container image for polkadot-omni-node/chain-spec-builder
+        if: ${{ env.BINARY == 'polkadot-omni-node' || env.BINARY == 'chain-spec-builder' }}
         env:
           ARTIFACTS_FOLDER: release-artifacts
           IMAGE_NAME: ${{ env.BINARY }}
@@ -266,8 +267,8 @@ jobs:
           username: ${{ secrets.POLKADOT_DOCKERHUB_USERNAME }}
           password: ${{ secrets.POLKADOT_DOCKERHUB_TOKEN }}
 
-      - name: Login to Dockerhub to puiblish polkadot-parachain/chain-spec-builder
-        if: ${{ env.BINARY == 'polkadot-parachain' || env.BINARY == 'chain-spec-builder' }}
+      - name: Login to Dockerhub to publish polkadot-omni-node/polkadot-parachain/chain-spec-builder
+        if: ${{ env.BINARY == 'polkadot-omni-node' || env.BINARY == 'polkadot-parachain' || env.BINARY == 'chain-spec-builder' }}
         uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
         with:
           username: ${{ secrets.CUMULUS_DOCKERHUB_USERNAME }}
@@ -315,7 +316,7 @@ jobs:
   build-polkadot-release-container: # this job will be triggered for polkadot release build
     if: ${{ inputs.binary == 'polkadot' && inputs.image_type == 'release' }}
     runs-on: ubuntu-latest
-    needs: [fetch-latest-debian-package-version, validate-inputs]
+    needs: [ fetch-latest-debian-package-version, validate-inputs ]
     environment: release
     steps:
       - name: Checkout sources
@@ -327,10 +328,10 @@ jobs:
       - name: Cache Docker layers
         uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
         with:
-         path: /tmp/.buildx-cache
-         key: ${{ runner.os }}-buildx-${{ github.sha }}
-         restore-keys: |
-           ${{ runner.os }}-buildx-
+          path: /tmp/.buildx-cache
+          key: ${{ runner.os }}-buildx-${{ github.sha }}
+          restore-keys: |
+            ${{ runner.os }}-buildx-
 
       - name: Login to Docker Hub
         uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
diff --git a/docker/scripts/polkadot-omni-node/build-injected.sh b/docker/scripts/polkadot-omni-node/build-injected.sh
new file mode 100755
index 00000000000..a39621bac3d
--- /dev/null
+++ b/docker/scripts/polkadot-omni-node/build-injected.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+# Sample call:
+# $0 /path/to/folder_with_binary
+# This script replace the former dedicated Dockerfile
+# and shows how to use the generic binary_injected.dockerfile
+
+PROJECT_ROOT=`git rev-parse --show-toplevel`
+
+export BINARY=polkadot-omni-node
+export ARTIFACTS_FOLDER=$1
+# export TAGS=...
+
+$PROJECT_ROOT/docker/scripts/build-injected.sh
-- 
GitLab