From 2a80b04015f46de8ddbae767927e801a7be07456 Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Tue, 23 Apr 2024 22:15:05 -0700 Subject: [PATCH 1/4] add ldlflag to node build --- .github/workflows/docker-publish-opr-node-images.yaml | 4 ++++ node/cmd/Dockerfile | 4 +++- node/config.go | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish-opr-node-images.yaml b/.github/workflows/docker-publish-opr-node-images.yaml index 4cb65f0d0a..0d64c596d8 100644 --- a/.github/workflows/docker-publish-opr-node-images.yaml +++ b/.github/workflows/docker-publish-opr-node-images.yaml @@ -6,6 +6,9 @@ on: commit_sha: description: 'Specific Commit SHA (Required)' required: true + version: + description: 'Version (Required)' + required: true release_tag: description: 'Release Tag (Optional)' required: false @@ -64,6 +67,7 @@ jobs: tags: ${{ env.REGISTRY }}/layr-labs/eigenda/opr-node:${{ steps.set_tag.outputs.tag }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new + build-args: SEMVER=${{ github.event.inputs.version }} if: ${{ success() }} - name: Build and Push NodePlugin Image diff --git a/node/cmd/Dockerfile b/node/cmd/Dockerfile index 91d62f84dc..922b2d8b38 100644 --- a/node/cmd/Dockerfile +++ b/node/cmd/Dockerfile @@ -1,5 +1,7 @@ FROM golang:1.21.1-alpine3.18 as builder +ARG SEMVER + RUN apk add --no-cache make musl-dev linux-headers gcc git jq bash # build node with local monorepo go modules @@ -16,7 +18,7 @@ COPY go.sum /app WORKDIR /app/node -RUN go build -o ./bin/node ./cmd +RUN go build -ldflags="-X 'node.SEMVER=${SEMVER}'" -o ./bin/node ./cmd FROM alpine:3.18 diff --git a/node/config.go b/node/config.go index a619c8be05..1244c971cf 100644 --- a/node/config.go +++ b/node/config.go @@ -23,7 +23,6 @@ const ( // Min number of seconds for the ExpirationPollIntervalSecFlag. minExpirationPollIntervalSec = 3 AppName = "da-node" - SemVer = "0.6.1" GitCommit = "" GitDate = "" ) @@ -35,6 +34,7 @@ var ( 0: "eth_quorum", 1: "permissioned_quorum", } + SemVer = "v0.0.0" ) // Config contains all of the configuration information for a DA node. From 1c0dd7c594136c51e236c2924e52acb24ddd770a Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Wed, 24 Apr 2024 07:02:44 -0700 Subject: [PATCH 2/4] update var --- node/cmd/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/cmd/Dockerfile b/node/cmd/Dockerfile index 922b2d8b38..5b42410d0e 100644 --- a/node/cmd/Dockerfile +++ b/node/cmd/Dockerfile @@ -18,7 +18,7 @@ COPY go.sum /app WORKDIR /app/node -RUN go build -ldflags="-X 'node.SEMVER=${SEMVER}'" -o ./bin/node ./cmd +RUN go build -ldflags="-X 'node.SemVer=${SEMVER}'" -o ./bin/node ./cmd FROM alpine:3.18 From 64e19046e9afa0532b2de8922752d51deafd8b20 Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Wed, 24 Apr 2024 15:51:00 -0700 Subject: [PATCH 3/4] Fix PR comment --- .github/workflows/docker-publish-opr-node-images.yaml | 8 +++++++- node/cmd/Dockerfile | 4 +++- node/config.go | 6 +++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-publish-opr-node-images.yaml b/.github/workflows/docker-publish-opr-node-images.yaml index 0d64c596d8..7156ab892c 100644 --- a/.github/workflows/docker-publish-opr-node-images.yaml +++ b/.github/workflows/docker-publish-opr-node-images.yaml @@ -9,6 +9,12 @@ on: version: description: 'Version (Required)' required: true + gitCommit: + description: 'GitCommit (Required)' + required: true + gitDate: + description: 'GitDate (Required)' + required: true release_tag: description: 'Release Tag (Optional)' required: false @@ -67,7 +73,7 @@ jobs: tags: ${{ env.REGISTRY }}/layr-labs/eigenda/opr-node:${{ steps.set_tag.outputs.tag }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new - build-args: SEMVER=${{ github.event.inputs.version }} + build-args: SEMVER=${{ github.event.inputs.version }},GITCOMMIT=${{ github.event.inputs.gitcommit }},DATE=${{ github.event.inputs.GitDate }} if: ${{ success() }} - name: Build and Push NodePlugin Image diff --git a/node/cmd/Dockerfile b/node/cmd/Dockerfile index 5b42410d0e..e47e1a8035 100644 --- a/node/cmd/Dockerfile +++ b/node/cmd/Dockerfile @@ -1,6 +1,8 @@ FROM golang:1.21.1-alpine3.18 as builder ARG SEMVER +ARG GITCOMMIT +ARG GITDATE RUN apk add --no-cache make musl-dev linux-headers gcc git jq bash @@ -18,7 +20,7 @@ COPY go.sum /app WORKDIR /app/node -RUN go build -ldflags="-X 'node.SemVer=${SEMVER}'" -o ./bin/node ./cmd +RUN go build -ldflags="-X 'node.SemVer=${SEMVER}' -X 'node.GitCommit=${GITCOMMIT}' -X 'node.GitDate=${GITDATE}'" -o ./bin/node ./cmd FROM alpine:3.18 diff --git a/node/config.go b/node/config.go index 1244c971cf..ca5999de13 100644 --- a/node/config.go +++ b/node/config.go @@ -23,8 +23,6 @@ const ( // Min number of seconds for the ExpirationPollIntervalSecFlag. minExpirationPollIntervalSec = 3 AppName = "da-node" - GitCommit = "" - GitDate = "" ) var ( @@ -34,7 +32,9 @@ var ( 0: "eth_quorum", 1: "permissioned_quorum", } - SemVer = "v0.0.0" + SemVer = "v0.0.0" + GitCommit = "" + GitDate = "" ) // Config contains all of the configuration information for a DA node. From 83c6311e1d17cb10f4d99cd9fba9be877e9cd3dd Mon Sep 17 00:00:00 2001 From: Siddharth More Date: Wed, 24 Apr 2024 16:30:17 -0700 Subject: [PATCH 4/4] Fix PR comment --- .../workflows/docker-publish-opr-node-images.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-publish-opr-node-images.yaml b/.github/workflows/docker-publish-opr-node-images.yaml index 7156ab892c..ed3aed9cc5 100644 --- a/.github/workflows/docker-publish-opr-node-images.yaml +++ b/.github/workflows/docker-publish-opr-node-images.yaml @@ -9,12 +9,9 @@ on: version: description: 'Version (Required)' required: true - gitCommit: + gitcommit: description: 'GitCommit (Required)' required: true - gitDate: - description: 'GitDate (Required)' - required: true release_tag: description: 'Release Tag (Optional)' required: false @@ -36,6 +33,12 @@ jobs: uses: actions/checkout@v3 with: ref: ${{ github.event.inputs.commit_sha }} + - name: Get Commit Date + id: get_date + run: | + GIT_DATE=$(git log -1 --format=%cd --date=format:'%Y-%m-%d' ${{ github.event.inputs.gitcommit }} || date '+%Y-%m-%d') + echo "GIT_DATE=$GIT_DATE" >> $GITHUB_ENV + echo "::set-output name=gitDate::$GIT_DATE" - name: Setup Buildx uses: docker/setup-buildx-action@v1 @@ -73,7 +76,7 @@ jobs: tags: ${{ env.REGISTRY }}/layr-labs/eigenda/opr-node:${{ steps.set_tag.outputs.tag }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new - build-args: SEMVER=${{ github.event.inputs.version }},GITCOMMIT=${{ github.event.inputs.gitcommit }},DATE=${{ github.event.inputs.GitDate }} + build-args: SEMVER=${{ github.event.inputs.version }},GITCOMMIT=${{ github.event.inputs.gitcommit }},GITDATE=${{ steps.get_date.outputs.gitDate }} if: ${{ success() }} - name: Build and Push NodePlugin Image