From 060c5e78e7ea5b3ef5fa4cd9b51cd81d91617a7d Mon Sep 17 00:00:00 2001 From: maancham Date: Fri, 22 Mar 2024 10:20:02 -0400 Subject: [PATCH 01/17] feat: testing out marketplace action for r2 connection --- .../build-binaries-and-push-to-r2.yaml | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/build-binaries-and-push-to-r2.yaml diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml new file mode 100644 index 000000000..0141792aa --- /dev/null +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -0,0 +1,37 @@ +name: Upload core binary to Cloudflare R2 bucket + + +on: + push: + + +jobs: + preparation: + name: Preparation + runs-on: ubuntu-22.04 + permissions: + contents: write + packages: write + id-token: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: "0" + submodules: recursive + + - name: Create a test file + run: | + cd ~/ + mkdir axelard + touch test.txt + mv test.txt axelard + + - uses: ryand56/r2-upload-action@latest + with: + r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} + r2-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_CF }} + r2-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CF }} + r2-bucket: ${{ secrets.R2_BUCKET }} + source-dir: axelard + destination-dir: ./ \ No newline at end of file From b79561d2a9f12a54f41c5ce9efb10da2764b57a5 Mon Sep 17 00:00:00 2001 From: maancham Date: Fri, 22 Mar 2024 10:24:53 -0400 Subject: [PATCH 02/17] fix: change source-dir to include slash --- .github/workflows/build-binaries-and-push-to-r2.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index 0141792aa..832d8990e 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -22,10 +22,7 @@ jobs: - name: Create a test file run: | - cd ~/ - mkdir axelard - touch test.txt - mv test.txt axelard + touch /test.txt - uses: ryand56/r2-upload-action@latest with: @@ -33,5 +30,5 @@ jobs: r2-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_CF }} r2-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CF }} r2-bucket: ${{ secrets.R2_BUCKET }} - source-dir: axelard + source-dir: /test.txt destination-dir: ./ \ No newline at end of file From fcca0acf2055c9fb4835366216efe3ac812e87f5 Mon Sep 17 00:00:00 2001 From: maancham Date: Fri, 22 Mar 2024 10:26:32 -0400 Subject: [PATCH 03/17] fix: add sudo to test file creation --- .github/workflows/build-binaries-and-push-to-r2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index 832d8990e..332f46fa8 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -22,7 +22,7 @@ jobs: - name: Create a test file run: | - touch /test.txt + sudo touch /test.txt - uses: ryand56/r2-upload-action@latest with: From db283962b5d78ca90690696480cf777464fea2e2 Mon Sep 17 00:00:00 2001 From: maancham Date: Fri, 22 Mar 2024 10:37:47 -0400 Subject: [PATCH 04/17] feat: add binary creation step and check commit hash --- .../build-binaries-and-push-to-r2.yaml | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index 332f46fa8..2e1f612b2 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -20,15 +20,22 @@ jobs: fetch-depth: "0" submodules: recursive - - name: Create a test file + - name: Build and rename axelard binary with commit hash run: | - sudo touch /test.txt + cd axelar-core + make build + commit_hash=$(git rev-parse --short HEAD) + echo "The commit hash: $commit_hash" + mkdir ./axelard_$commit_hash/ + sudo mv bin/axelard ./axelard_$commit_hash/ + ls -la ./axelard_$commit_hash/ + - - uses: ryand56/r2-upload-action@latest - with: - r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} - r2-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_CF }} - r2-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CF }} - r2-bucket: ${{ secrets.R2_BUCKET }} - source-dir: /test.txt - destination-dir: ./ \ No newline at end of file + # - uses: ryand56/r2-upload-action@latest + # with: + # r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} + # r2-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_CF }} + # r2-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CF }} + # r2-bucket: ${{ secrets.R2_BUCKET }} + # source-dir: /test.txt + # destination-dir: ./ \ No newline at end of file From a097fdb444c5a00ed3b31db3b4456b9a6bccccda Mon Sep 17 00:00:00 2001 From: maancham Date: Fri, 22 Mar 2024 10:40:01 -0400 Subject: [PATCH 05/17] fix: add path to checkout --- .github/workflows/build-binaries-and-push-to-r2.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index 2e1f612b2..025cec16d 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -18,6 +18,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: "0" + path: axelar-core submodules: recursive - name: Build and rename axelard binary with commit hash From 12fcbc97c1e50a162fbc31b2bd0164498e285159 Mon Sep 17 00:00:00 2001 From: maancham Date: Fri, 22 Mar 2024 10:45:14 -0400 Subject: [PATCH 06/17] feat: add binary dir to r2 step as source --- .../build-binaries-and-push-to-r2.yaml | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index 025cec16d..44e250185 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -21,7 +21,8 @@ jobs: path: axelar-core submodules: recursive - - name: Build and rename axelard binary with commit hash + - name: Build axelard binary with commit hash + id: build-binary run: | cd axelar-core make build @@ -29,14 +30,14 @@ jobs: echo "The commit hash: $commit_hash" mkdir ./axelard_$commit_hash/ sudo mv bin/axelard ./axelard_$commit_hash/ - ls -la ./axelard_$commit_hash/ + echo "binary-directory=./axelard_$commit_hash/" >> $GITHUB_OUTPUT - # - uses: ryand56/r2-upload-action@latest - # with: - # r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} - # r2-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_CF }} - # r2-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CF }} - # r2-bucket: ${{ secrets.R2_BUCKET }} - # source-dir: /test.txt - # destination-dir: ./ \ No newline at end of file + - uses: ryand56/r2-upload-action@latest + with: + r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} + r2-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_CF }} + r2-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CF }} + r2-bucket: ${{ secrets.R2_BUCKET }} + source-dir: ${{ steps.build-binary.outputs.binary-directory }} + destination-dir: ./ \ No newline at end of file From df1bc300a5d159fe16866449bc9a1a05ed5b3642 Mon Sep 17 00:00:00 2001 From: maancham Date: Fri, 22 Mar 2024 10:49:55 -0400 Subject: [PATCH 07/17] fix: remove trailing slash from path --- .github/workflows/build-binaries-and-push-to-r2.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index 44e250185..6e605631b 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -30,9 +30,11 @@ jobs: echo "The commit hash: $commit_hash" mkdir ./axelard_$commit_hash/ sudo mv bin/axelard ./axelard_$commit_hash/ - echo "binary-directory=./axelard_$commit_hash/" >> $GITHUB_OUTPUT + echo "binary-directory=./axelard_$commit_hash" >> $GITHUB_OUTPUT - + - name: List contents of root directory + run: ls -la + - uses: ryand56/r2-upload-action@latest with: r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} From 0f5d43bdd38a27a59ec6286dc3a7c03eb27ae090 Mon Sep 17 00:00:00 2001 From: maancham Date: Fri, 22 Mar 2024 10:55:29 -0400 Subject: [PATCH 08/17] fix: cd back to root before mkdir --- .github/workflows/build-binaries-and-push-to-r2.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index 6e605631b..b36359512 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -28,8 +28,9 @@ jobs: make build commit_hash=$(git rev-parse --short HEAD) echo "The commit hash: $commit_hash" + cd .. mkdir ./axelard_$commit_hash/ - sudo mv bin/axelard ./axelard_$commit_hash/ + sudo mv axelar-core/bin/axelard ./axelard_$commit_hash/ echo "binary-directory=./axelard_$commit_hash" >> $GITHUB_OUTPUT - name: List contents of root directory From 94c4d24a0f6235f1a7ed6dfea68ebf4d29a659f7 Mon Sep 17 00:00:00 2001 From: maancham Date: Fri, 22 Mar 2024 11:02:01 -0400 Subject: [PATCH 09/17] feat: change filename to include commit hash, add r2 destination path --- .github/workflows/build-binaries-and-push-to-r2.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index b36359512..28bba4152 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -24,14 +24,14 @@ jobs: - name: Build axelard binary with commit hash id: build-binary run: | + mkdir ./binary_file/ cd axelar-core make build commit_hash=$(git rev-parse --short HEAD) echo "The commit hash: $commit_hash" cd .. - mkdir ./axelard_$commit_hash/ - sudo mv axelar-core/bin/axelard ./axelard_$commit_hash/ - echo "binary-directory=./axelard_$commit_hash" >> $GITHUB_OUTPUT + sudo mv axelar-core/bin/axelard ./binary_file/axelard_$commit_hash + echo "binary-directory=./binary_file" >> $GITHUB_OUTPUT - name: List contents of root directory run: ls -la @@ -43,4 +43,4 @@ jobs: r2-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CF }} r2-bucket: ${{ secrets.R2_BUCKET }} source-dir: ${{ steps.build-binary.outputs.binary-directory }} - destination-dir: ./ \ No newline at end of file + destination-dir: ./pre-releases/axelard/ \ No newline at end of file From 21ba4ed0deae1d9f7a02791e5f451fc779c30a84 Mon Sep 17 00:00:00 2001 From: maancham Date: Fri, 22 Mar 2024 11:06:47 -0400 Subject: [PATCH 10/17] chore: clean up for PR --- .github/workflows/build-binaries-and-push-to-r2.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index 28bba4152..45e8a89ee 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -1,13 +1,13 @@ name: Upload core binary to Cloudflare R2 bucket - on: - push: - + push: + branches: + - '*' jobs: - preparation: - name: Preparation + build-and-upload: + name: Build binary from current commit and push to R2 runs-on: ubuntu-22.04 permissions: contents: write From 135456f4b98900ea2802311f0b663bb8d129cb58 Mon Sep 17 00:00:00 2001 From: maancham Date: Mon, 25 Mar 2024 09:37:58 -0400 Subject: [PATCH 11/17] refactor: use semver for binary naming, change auto run to main branch only --- .github/workflows/build-binaries-and-push-to-r2.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index 45e8a89ee..b38dadd53 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -3,7 +3,8 @@ name: Upload core binary to Cloudflare R2 bucket on: push: branches: - - '*' + - main + workflow_dispatch: jobs: build-and-upload: @@ -21,16 +22,16 @@ jobs: path: axelar-core submodules: recursive - - name: Build axelard binary with commit hash + - name: Build axelard binary with version and commit hash id: build-binary run: | mkdir ./binary_file/ cd axelar-core make build - commit_hash=$(git rev-parse --short HEAD) - echo "The commit hash: $commit_hash" + semver=$(git describe --tags) + echo "Semantic Version of current binary: $semver" cd .. - sudo mv axelar-core/bin/axelard ./binary_file/axelard_$commit_hash + sudo mv axelar-core/bin/axelard ./binary_file/axelard-linux-amd64-$semver echo "binary-directory=./binary_file" >> $GITHUB_OUTPUT - name: List contents of root directory From 51083fac70bc598bb4141ec578a9106682a6fa89 Mon Sep 17 00:00:00 2001 From: maancham Date: Mon, 25 Mar 2024 09:53:48 -0400 Subject: [PATCH 12/17] feat: add branch input, edit checkout step --- .../build-binaries-and-push-to-r2.yaml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index b38dadd53..65f1bd60d 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -5,22 +5,39 @@ on: branches: - main workflow_dispatch: + inputs: + branch: + description: Github branch to checkout for build + required: true + default: main + type: string jobs: build-and-upload: - name: Build binary from current commit and push to R2 + name: Build binary and push to R2 runs-on: ubuntu-22.04 permissions: contents: write packages: write id-token: write steps: + - name: Determine branch + id: get-branch-name + run: | + if [ "${{ github.event_name }}" == "push" ]; then + branch="main" + else + branch="${{ inputs.branch }}" + fi + echo "branch=branch" >> $GITHUB_OUTPUT + - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: "0" path: axelar-core submodules: recursive + ref: ${{ steps.get-branch-name.outputs.branch }} - name: Build axelard binary with version and commit hash id: build-binary From 9e020ca1a02ab56b232fc3fbe0bfea5f3ee0dea1 Mon Sep 17 00:00:00 2001 From: maancham Date: Mon, 25 Mar 2024 10:31:45 -0400 Subject: [PATCH 13/17] fix: change binary var to use variable instead of string --- .github/workflows/build-binaries-and-push-to-r2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index 65f1bd60d..1f06ba73b 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -29,7 +29,7 @@ jobs: else branch="${{ inputs.branch }}" fi - echo "branch=branch" >> $GITHUB_OUTPUT + echo "branch=$branch" >> $GITHUB_OUTPUT - name: Checkout code uses: actions/checkout@v4 From c9ccaa8e685dd659a2e370f524c04ceeaaed5496 Mon Sep 17 00:00:00 2001 From: Christian Gorenflo Date: Mon, 25 Mar 2024 19:01:19 -0400 Subject: [PATCH 14/17] Update .github/workflows/build-binaries-and-push-to-r2.yaml --- .github/workflows/build-binaries-and-push-to-r2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index 1f06ba73b..c77be452a 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -61,4 +61,4 @@ jobs: r2-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CF }} r2-bucket: ${{ secrets.R2_BUCKET }} source-dir: ${{ steps.build-binary.outputs.binary-directory }} - destination-dir: ./pre-releases/axelard/ \ No newline at end of file + destination-dir: ./pre-releases/axelard/ From 6a758dd0aa6148b25fa4b4703bbdd51599b5bf5f Mon Sep 17 00:00:00 2001 From: maancham Date: Tue, 26 Mar 2024 11:44:36 -0400 Subject: [PATCH 15/17] refactor: move to ubuntu-20.04 for consistency --- .github/workflows/build-binaries-and-push-to-r2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-binaries-and-push-to-r2.yaml b/.github/workflows/build-binaries-and-push-to-r2.yaml index c77be452a..957fa4641 100644 --- a/.github/workflows/build-binaries-and-push-to-r2.yaml +++ b/.github/workflows/build-binaries-and-push-to-r2.yaml @@ -15,7 +15,7 @@ on: jobs: build-and-upload: name: Build binary and push to R2 - runs-on: ubuntu-22.04 + runs-on: ubuntu-20.04 permissions: contents: write packages: write From d85a753624b52b665dfa246bfe9b4579490ced6a Mon Sep 17 00:00:00 2001 From: maancham Date: Tue, 26 Mar 2024 11:58:49 -0400 Subject: [PATCH 16/17] feat: add upload to CF for releases action --- .github/workflows/build-docker-image-and-binaries.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/build-docker-image-and-binaries.yaml b/.github/workflows/build-docker-image-and-binaries.yaml index 4773b4138..bed2c332c 100644 --- a/.github/workflows/build-docker-image-and-binaries.yaml +++ b/.github/workflows/build-docker-image-and-binaries.yaml @@ -130,6 +130,15 @@ jobs: S3_PATH: s3://axelar-releases/axelard/${{ github.event.inputs.tag }} run: | aws s3 cp ./bin ${S3_PATH}/ --recursive + + - uses: ryand56/r2-upload-action@latest + with: + r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} + r2-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_CF }} + r2-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CF }} + r2-bucket: ${{ secrets.R2_BUCKET }} + source-dir: ./bin + destination-dir: ./releases/axelard/ release-docker: From b5c04b6467dfd6c06a050e104c8f4079e9ec208f Mon Sep 17 00:00:00 2001 From: Houmaan Chamani Date: Tue, 26 Mar 2024 12:13:04 -0400 Subject: [PATCH 17/17] refactor: add name to r2 upload step Co-authored-by: Milap Sheth --- .github/workflows/build-docker-image-and-binaries.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-docker-image-and-binaries.yaml b/.github/workflows/build-docker-image-and-binaries.yaml index bed2c332c..8e3d0325d 100644 --- a/.github/workflows/build-docker-image-and-binaries.yaml +++ b/.github/workflows/build-docker-image-and-binaries.yaml @@ -131,6 +131,7 @@ jobs: run: | aws s3 cp ./bin ${S3_PATH}/ --recursive + - name: Upload binaries to Cloudflare R2 - uses: ryand56/r2-upload-action@latest with: r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}