From 0e2fa2d1f9ea939523b3eb48c37037c96d00c501 Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 10:58:01 -0400 Subject: [PATCH 01/16] chore: test commit with skip tag [skip ci] --- .github/workflows/build-contracts-and-push-to-r2.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index 0067c8f8d..435623566 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -4,6 +4,7 @@ on: push: branches: - main + - fix/ignore-skip-ci-for-r2-action workflow_dispatch: inputs: branch: @@ -21,6 +22,11 @@ jobs: contents: write packages: write id-token: write + if: | + github.event_name == 'workflow_dispatch' || + (github.event_name == 'push' && + (github.ref == 'refs/heads/fix/ignore-skip-ci-for-r2-action' || + !contains(github.event.head_commit.message, '[skip ci]'))) steps: - name: Determine branch id: get-branch-name From bf8e7485e1bbb55bcf7fd880a98ef63f0c8b21c4 Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 11:01:39 -0400 Subject: [PATCH 02/16] chore: add logger step at the beginning of job --- .../build-contracts-and-push-to-r2.yaml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index 435623566..95134aeea 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -22,12 +22,20 @@ jobs: contents: write packages: write id-token: write - if: | - github.event_name == 'workflow_dispatch' || - (github.event_name == 'push' && - (github.ref == 'refs/heads/fix/ignore-skip-ci-for-r2-action' || - !contains(github.event.head_commit.message, '[skip ci]'))) steps: + - name: Log condition variables + run: | + echo "Logging condition variables:" + echo "github.event_name: ${{ github.event_name }}" + echo "github.ref: ${{ github.ref }}" + echo "github.event.head_commit.message: ${{ github.event.head_commit.message }}" + echo "Contains [skip ci]: ${{ contains(github.event.head_commit.message, '[skip ci]') }}" + echo "Condition evaluation: ${{ + github.event_name == 'workflow_dispatch' || + (github.event_name == 'push' && + (github.ref == 'refs/heads/fix/ignore-skip-ci-for-r2-action' || + !contains(github.event.head_commit.message, '[skip ci]'))) + }}" - name: Determine branch id: get-branch-name run: | From 4f517a527b0465819d18ec0caa70bef2fb26a496 Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 11:47:41 -0400 Subject: [PATCH 03/16] chore: release in a test setting --- .../build-contracts-and-push-to-r2.yaml | 63 +++++++++---------- release.toml | 2 +- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index 95134aeea..dace99f77 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -23,19 +23,12 @@ jobs: packages: write id-token: write steps: - - name: Log condition variables + - name: Determine if commit is a release run: | - echo "Logging condition variables:" - echo "github.event_name: ${{ github.event_name }}" - echo "github.ref: ${{ github.ref }}" - echo "github.event.head_commit.message: ${{ github.event.head_commit.message }}" - echo "Contains [skip ci]: ${{ contains(github.event.head_commit.message, '[skip ci]') }}" - echo "Condition evaluation: ${{ - github.event_name == 'workflow_dispatch' || - (github.event_name == 'push' && - (github.ref == 'refs/heads/fix/ignore-skip-ci-for-r2-action' || - !contains(github.event.head_commit.message, '[skip ci]'))) - }}" + is_release=${{ contains(github.event.head_commit.message, 'chore: release') }}" + echo "Does commit belong to a release: ${{ is_release }}" + echo "is-release=is_release" >> $GITHUB_OUTPUT + - name: Determine branch id: get-branch-name run: | @@ -54,26 +47,26 @@ jobs: submodules: recursive ref: ${{ steps.get-branch-name.outputs.branch }} - - name: Compile amplifier contracts - id: compile-contracts - run: | - cd axelar-amplifier - docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ - --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/optimizer:0.16.0 - - commit_hash=$(git rev-parse --short HEAD) - cd .. - mkdir -p ./artifacts/$commit_hash/ - cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/ - echo "wasm-directory=./artifacts" >> $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: ${{ steps.compile-contracts.outputs.wasm-directory }} - destination-dir: ./pre-releases/ampd/contracts/ +# - name: Compile amplifier contracts +# id: compile-contracts +# run: | +# cd axelar-amplifier +# docker run --rm -v "$(pwd)":/code \ +# --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ +# --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ +# cosmwasm/optimizer:0.16.0 +# +# commit_hash=$(git rev-parse --short HEAD) +# cd .. +# mkdir -p ./artifacts/$commit_hash/ +# cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/ +# echo "wasm-directory=./artifacts" >> $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: ${{ steps.compile-contracts.outputs.wasm-directory }} +# destination-dir: ./pre-releases/ampd/contracts/ diff --git a/release.toml b/release.toml index da7a87a48..7259e24f6 100644 --- a/release.toml +++ b/release.toml @@ -1,4 +1,4 @@ -pre-release-commit-message = "chore: release {{crate_name}} {{version}} [skip ci]" +pre-release-commit-message = "chore: release {{crate_name}} {{version}}" consolidate-commits = false release = true publish = false From 5da5df496369d13ec3b76052867f276a8be6f7cc Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 11:49:10 -0400 Subject: [PATCH 04/16] chore: add new branch name to on push setting --- .github/workflows/build-contracts-and-push-to-r2.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index dace99f77..85bd91841 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -4,7 +4,7 @@ on: push: branches: - main - - fix/ignore-skip-ci-for-r2-action + - fix/push-releases-to-r2 workflow_dispatch: inputs: branch: @@ -25,9 +25,9 @@ jobs: steps: - name: Determine if commit is a release run: | - is_release=${{ contains(github.event.head_commit.message, 'chore: release') }}" - echo "Does commit belong to a release: ${{ is_release }}" - echo "is-release=is_release" >> $GITHUB_OUTPUT + is_release=${{ contains(github.event.head_commit.message, 'chore: release') }} + echo "Does commit belong to a release: $is_release" + echo "is-release=$is_release" >> $GITHUB_OUTPUT - name: Determine branch id: get-branch-name From 041fe5916622f29be713c25cc5c38e09e0c9d6f7 Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 11:53:45 -0400 Subject: [PATCH 05/16] chore: release voting-verifier 0.4.3 --- .../build-contracts-and-push-to-r2.yaml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index 85bd91841..dd6581cbf 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -23,11 +23,27 @@ jobs: packages: write id-token: write steps: - - name: Determine if commit is a release + - name: Check for release information if present + id: check-release run: | + commit_message="${{ github.event.head_commit.message }}" is_release=${{ contains(github.event.head_commit.message, 'chore: release') }} echo "Does commit belong to a release: $is_release" echo "is-release=$is_release" >> $GITHUB_OUTPUT + + if [ "$is_release" = "true" ]; then + release_info=$(echo "$commit_message" | sed -n 's/chore: release \(.*\) \(.*\)/\1 \2/p') + crate_name=$(echo $release_info | cut -d' ' -f1) + version=$(echo $release_info | cut -d' ' -f2) + + echo "Crate Name: $crate_name" + echo "Version: $version" + + echo "crate-name=$crate_name" >> $GITHUB_OUTPUT + echo "crate-version=$version" >> $GITHUB_OUTPUT + else + echo "Not a release commit. Skipping crate name and version extraction." + fi - name: Determine branch id: get-branch-name From edd5eab1b1a46fce42f7397ee5384f6420e22640 Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 12:05:32 -0400 Subject: [PATCH 06/16] chore: release service-registry 0.3 --- .../build-contracts-and-push-to-r2.yaml | 57 ++++++++++++++----- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index dd6581cbf..386a994e9 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -45,6 +45,7 @@ jobs: echo "Not a release commit. Skipping crate name and version extraction." fi + - name: Determine branch id: get-branch-name run: | @@ -55,6 +56,7 @@ jobs: fi echo "branch=$branch" >> $GITHUB_OUTPUT + - name: Checkout code uses: actions/checkout@v4 with: @@ -63,21 +65,46 @@ jobs: submodules: recursive ref: ${{ steps.get-branch-name.outputs.branch }} -# - name: Compile amplifier contracts -# id: compile-contracts -# run: | -# cd axelar-amplifier -# docker run --rm -v "$(pwd)":/code \ -# --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ -# --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ -# cosmwasm/optimizer:0.16.0 -# -# commit_hash=$(git rev-parse --short HEAD) -# cd .. -# mkdir -p ./artifacts/$commit_hash/ -# cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/ -# echo "wasm-directory=./artifacts" >> $GITHUB_OUTPUT -# + + - name: Compile amplifier contracts + id: compile-contracts + run: | + cd axelar-amplifier + docker run --rm -v "$(pwd)":/code \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/optimizer:0.16.0 + + commit_hash=$(git rev-parse --short HEAD) + cd .. + mkdir -p ./artifacts/$commit_hash/ + cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/ + echo "wasm-directory=./artifacts" >> $GITHUB_OUTPUT + + - name: Prepare release artifacts + if: steps.check-release.outputs.is-release == 'true' + id: prepare-release + run: | + cd ${{ steps.compile-contracts.outputs.wasm-directory }} + crate_name="${{ steps.check-release.outputs.crate-name }}" + crate_version="${{ steps.check-release.outputs.crate-version }}" + wasm_file=$(find . -name "${crate_name//-/_}.wasm") + + if [ -z "$wasm_file" ]; then + echo "Error: Could not find .wasm file for $crate_name" + exit 1 + fi + + mkdir -p "../release-artifacts" + cp "$wasm_file" "../release-artifacts/${crate_name}.wasm" + cp checksums.txt "../release-artifacts/" + + echo "release-artifacts-dir=./artifacts/release-artifacts" >> $GITHUB_OUTPUT + echo "r2-destination-dir=./releases/amplifier/${crate_name}/${crate_version}" >> $GITHUB_OUTPUT + + ls -la ../release-artifacts/ + + # - uses: ryand56/r2-upload-action@latest # with: # r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} From 2bcaead9d7d3ec7c309258a2ad5281d004effa4d Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 12:23:57 -0400 Subject: [PATCH 07/16] chore: release service-registry 0.2 --- .github/workflows/build-contracts-and-push-to-r2.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index 386a994e9..6affc2fbe 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -89,15 +89,20 @@ jobs: crate_name="${{ steps.check-release.outputs.crate-name }}" crate_version="${{ steps.check-release.outputs.crate-version }}" wasm_file=$(find . -name "${crate_name//-/_}.wasm") + checksum_file=$(find . -name "checksums.txt") if [ -z "$wasm_file" ]; then echo "Error: Could not find .wasm file for $crate_name" exit 1 fi + ls -la + echo "Wasm file: $wasm_file" + echo "Checksum file: $checksum_file" + mkdir -p "../release-artifacts" cp "$wasm_file" "../release-artifacts/${crate_name}.wasm" - cp checksums.txt "../release-artifacts/" + cp "$checksum_file" "../release-artifacts/" echo "release-artifacts-dir=./artifacts/release-artifacts" >> $GITHUB_OUTPUT echo "r2-destination-dir=./releases/amplifier/${crate_name}/${crate_version}" >> $GITHUB_OUTPUT From 760ebe969c4525e26eba0f4c921dd85b6c2ed5c1 Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 12:52:29 -0400 Subject: [PATCH 08/16] chore: release service-registry 0.2.5 --- .../build-contracts-and-push-to-r2.yaml | 95 ++++++++++++------- 1 file changed, 60 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index 6affc2fbe..7e435a19c 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -66,48 +66,73 @@ jobs: ref: ${{ steps.get-branch-name.outputs.branch }} - - name: Compile amplifier contracts - id: compile-contracts - run: | - cd axelar-amplifier - docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ - --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/optimizer:0.16.0 + - name: Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v4 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} - commit_hash=$(git rev-parse --short HEAD) - cd .. - mkdir -p ./artifacts/$commit_hash/ - cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/ - echo "wasm-directory=./artifacts" >> $GITHUB_OUTPUT - - name: Prepare release artifacts + - name: Compile a single amplifier contract if: steps.check-release.outputs.is-release == 'true' - id: prepare-release + id: compile-single-contract run: | - cd ${{ steps.compile-contracts.outputs.wasm-directory }} crate_name="${{ steps.check-release.outputs.crate-name }}" - crate_version="${{ steps.check-release.outputs.crate-version }}" - wasm_file=$(find . -name "${crate_name//-/_}.wasm") - checksum_file=$(find . -name "checksums.txt") - - if [ -z "$wasm_file" ]; then - echo "Error: Could not find .wasm file for $crate_name" - exit 1 - fi + cd axelar-amplifier/contracts/$crate_name - ls -la - echo "Wasm file: $wasm_file" - echo "Checksum file: $checksum_file" - - mkdir -p "../release-artifacts" - cp "$wasm_file" "../release-artifacts/${crate_name}.wasm" - cp "$checksum_file" "../release-artifacts/" - - echo "release-artifacts-dir=./artifacts/release-artifacts" >> $GITHUB_OUTPUT - echo "r2-destination-dir=./releases/amplifier/${crate_name}/${crate_version}" >> $GITHUB_OUTPUT + docker run --rm -v "$(pwd)":/code \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/optimizer:0.16.0 - ls -la ../release-artifacts/ + ls -la ./artifacts + + +# - name: Compile all amplifier contracts +# if: steps.check-release.outputs.is-release != 'true' +# id: compile-contracts +# run: | +# cd axelar-amplifier +# docker run --rm -v "$(pwd)":/code \ +# --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ +# --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ +# cosmwasm/optimizer:0.16.0 +# +# commit_hash=$(git rev-parse --short HEAD) +# cd .. +# mkdir -p ./artifacts/$commit_hash/ +# cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/ +# echo "wasm-directory=./artifacts" >> $GITHUB_OUTPUT +# +# +# - name: Prepare release artifacts +# if: steps.check-release.outputs.is-release == 'true' +# id: prepare-release +# run: | +# cd ${{ steps.compile-contracts.outputs.wasm-directory }} +# crate_name="${{ steps.check-release.outputs.crate-name }}" +# crate_version="${{ steps.check-release.outputs.crate-version }}" +# wasm_file=$(find . -name "${crate_name//-/_}.wasm") +# checksum_file=$(find . -name "checksums.txt") +# +# if [ -z "$wasm_file" ]; then +# echo "Error: Could not find .wasm file for $crate_name" +# exit 1 +# fi +# +# ls -la +# echo "Wasm file: $wasm_file" +# echo "Checksum file: $checksum_file" +# +# mkdir -p "../release-artifacts" +# cp "$wasm_file" "../release-artifacts/${crate_name}.wasm" +# cp "$checksum_file" "../release-artifacts/" +# +# echo "release-artifacts-dir=./artifacts/release-artifacts" >> $GITHUB_OUTPUT +# echo "r2-destination-dir=./releases/amplifier/${crate_name}/${crate_version}" >> $GITHUB_OUTPUT +# +# ls -la ../release-artifacts/ # - uses: ryand56/r2-upload-action@latest From d527506ab0f19cf22b00b24b0cc0416f3043771d Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 13:19:21 -0400 Subject: [PATCH 09/16] chore: release service-registry 0.6 --- .../build-contracts-and-push-to-r2.yaml | 97 +++++++++---------- 1 file changed, 44 insertions(+), 53 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index 7e435a19c..e1dcb1f97 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -74,66 +74,57 @@ jobs: passphrase: ${{ secrets.GPG_PASSPHRASE }} - - name: Compile a single amplifier contract - if: steps.check-release.outputs.is-release == 'true' - id: compile-single-contract + - name: Compile all amplifier contracts + id: compile-contracts run: | - crate_name="${{ steps.check-release.outputs.crate-name }}" - cd axelar-amplifier/contracts/$crate_name - + cd axelar-amplifier docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/optimizer:0.16.0 + + commit_hash=$(git rev-parse --short HEAD) + cd .. + mkdir -p ./artifacts/$commit_hash/ + cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/ + echo "wasm-directory=./artifacts" >> $GITHUB_OUTPUT + + + - name: Prepare and sign release artifacts + if: steps.check-release.outputs.is-release == 'true' + id: prepare-release + run: | + cd ${{ steps.compile-contracts.outputs.wasm-directory }} + crate_name="${{ steps.check-release.outputs.crate-name }}" + crate_version="${{ steps.check-release.outputs.crate-version }}" + wasm_file=$(find . -name "${crate_name//-/_}.wasm") + checksum_file=$(find . -name "checksums.txt") + + if [ -z "$wasm_file" ]; then + echo "Error: Could not find .wasm file for $crate_name" + exit 1 + fi + + mkdir -p "../release-artifacts" + cp "$wasm_file" "../release-artifacts/${crate_name}.wasm" + cp "$checksum_file" "../release-artifacts/" - ls -la ./artifacts - - -# - name: Compile all amplifier contracts -# if: steps.check-release.outputs.is-release != 'true' -# id: compile-contracts -# run: | -# cd axelar-amplifier -# docker run --rm -v "$(pwd)":/code \ -# --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ -# --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ -# cosmwasm/optimizer:0.16.0 -# -# commit_hash=$(git rev-parse --short HEAD) -# cd .. -# mkdir -p ./artifacts/$commit_hash/ -# cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/ -# echo "wasm-directory=./artifacts" >> $GITHUB_OUTPUT -# -# -# - name: Prepare release artifacts -# if: steps.check-release.outputs.is-release == 'true' -# id: prepare-release -# run: | -# cd ${{ steps.compile-contracts.outputs.wasm-directory }} -# crate_name="${{ steps.check-release.outputs.crate-name }}" -# crate_version="${{ steps.check-release.outputs.crate-version }}" -# wasm_file=$(find . -name "${crate_name//-/_}.wasm") -# checksum_file=$(find . -name "checksums.txt") -# -# if [ -z "$wasm_file" ]; then -# echo "Error: Could not find .wasm file for $crate_name" -# exit 1 -# fi -# -# ls -la -# echo "Wasm file: $wasm_file" -# echo "Checksum file: $checksum_file" -# -# mkdir -p "../release-artifacts" -# cp "$wasm_file" "../release-artifacts/${crate_name}.wasm" -# cp "$checksum_file" "../release-artifacts/" -# -# echo "release-artifacts-dir=./artifacts/release-artifacts" >> $GITHUB_OUTPUT -# echo "r2-destination-dir=./releases/amplifier/${crate_name}/${crate_version}" >> $GITHUB_OUTPUT -# -# ls -la ../release-artifacts/ + gpg --armor --detach-sign ../release-artifacts/${crate_name}.wasm + gpg --armor --detach-sign ../release-artifacts/checksums.txt + echo "release-artifacts-dir=./release-artifacts" >> $GITHUB_OUTPUT + echo "r2-destination-dir=./releases/amplifier/${crate_name}/${crate_version}" >> $GITHUB_OUTPUT + + + - uses: ryand56/r2-upload-action@latest + if: steps.check-release.outputs.is-release == 'true' + 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.prepare-release.outputs.release-artifacts-dir }} + destination-dir: ${{ steps.prepare-release.outputs.r2-destination-dir }} # - uses: ryand56/r2-upload-action@latest # with: From 997001f57914978e6459ed2df228ef50cd7650d2 Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 13:46:54 -0400 Subject: [PATCH 10/16] refactor: cleanup for PR --- .../build-contracts-and-push-to-r2.yaml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index e1dcb1f97..08af10e98 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -4,7 +4,6 @@ on: push: branches: - main - - fix/push-releases-to-r2 workflow_dispatch: inputs: branch: @@ -126,11 +125,13 @@ jobs: source-dir: ${{ steps.prepare-release.outputs.release-artifacts-dir }} destination-dir: ${{ steps.prepare-release.outputs.r2-destination-dir }} -# - 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.compile-contracts.outputs.wasm-directory }} -# destination-dir: ./pre-releases/ampd/contracts/ + + - uses: ryand56/r2-upload-action@latest + if: steps.check-release.outputs.is-release != 'true' + 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.compile-contracts.outputs.wasm-directory }} + destination-dir: ./pre-releases/ampd/contracts/ From e0e88afe5dd8de753ceb1a0466a7b1ef8dc3a804 Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 20:28:34 -0400 Subject: [PATCH 11/16] chore: testing out tag extraction from ref name --- .../build-contracts-and-push-to-r2.yaml | 230 +++++++++--------- 1 file changed, 121 insertions(+), 109 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index 08af10e98..9bbf3622d 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -4,6 +4,7 @@ on: push: branches: - main + - fix/push-releases-to-r2 workflow_dispatch: inputs: branch: @@ -22,116 +23,127 @@ jobs: packages: write id-token: write steps: - - name: Check for release information if present - id: check-release + - name: Get tag + id: get-tag run: | - commit_message="${{ github.event.head_commit.message }}" - is_release=${{ contains(github.event.head_commit.message, 'chore: release') }} - echo "Does commit belong to a release: $is_release" - echo "is-release=$is_release" >> $GITHUB_OUTPUT - - if [ "$is_release" = "true" ]; then - release_info=$(echo "$commit_message" | sed -n 's/chore: release \(.*\) \(.*\)/\1 \2/p') - crate_name=$(echo $release_info | cut -d' ' -f1) - version=$(echo $release_info | cut -d' ' -f2) - - echo "Crate Name: $crate_name" - echo "Version: $version" - - echo "crate-name=$crate_name" >> $GITHUB_OUTPUT - echo "crate-version=$version" >> $GITHUB_OUTPUT + echo "github ref name: ${{ github.ref_name }}" + echo "github event release tag name: ${{ github.event.release.tag_name }}" + if [[ $GITHUB_REF == refs/tags/* ]]; then + echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT else - echo "Not a release commit. Skipping crate name and version extraction." + echo "tag=" >> $GITHUB_OUTPUT fi - - - 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-amplifier - submodules: recursive - ref: ${{ steps.get-branch-name.outputs.branch }} - - - - name: Import GPG key - id: import_gpg - uses: crazy-max/ghaction-import-gpg@v4 - with: - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.GPG_PASSPHRASE }} - - - - name: Compile all amplifier contracts - id: compile-contracts - run: | - cd axelar-amplifier - docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ - --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/optimizer:0.16.0 - - commit_hash=$(git rev-parse --short HEAD) - cd .. - mkdir -p ./artifacts/$commit_hash/ - cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/ - echo "wasm-directory=./artifacts" >> $GITHUB_OUTPUT - - - - name: Prepare and sign release artifacts - if: steps.check-release.outputs.is-release == 'true' - id: prepare-release - run: | - cd ${{ steps.compile-contracts.outputs.wasm-directory }} - crate_name="${{ steps.check-release.outputs.crate-name }}" - crate_version="${{ steps.check-release.outputs.crate-version }}" - wasm_file=$(find . -name "${crate_name//-/_}.wasm") - checksum_file=$(find . -name "checksums.txt") - - if [ -z "$wasm_file" ]; then - echo "Error: Could not find .wasm file for $crate_name" - exit 1 - fi - - mkdir -p "../release-artifacts" - cp "$wasm_file" "../release-artifacts/${crate_name}.wasm" - cp "$checksum_file" "../release-artifacts/" - - gpg --armor --detach-sign ../release-artifacts/${crate_name}.wasm - gpg --armor --detach-sign ../release-artifacts/checksums.txt - - echo "release-artifacts-dir=./release-artifacts" >> $GITHUB_OUTPUT - echo "r2-destination-dir=./releases/amplifier/${crate_name}/${crate_version}" >> $GITHUB_OUTPUT - - - - uses: ryand56/r2-upload-action@latest - if: steps.check-release.outputs.is-release == 'true' - 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.prepare-release.outputs.release-artifacts-dir }} - destination-dir: ${{ steps.prepare-release.outputs.r2-destination-dir }} - - - - uses: ryand56/r2-upload-action@latest - if: steps.check-release.outputs.is-release != 'true' - 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.compile-contracts.outputs.wasm-directory }} - destination-dir: ./pre-releases/ampd/contracts/ +# - name: Check for release information if present +# id: check-release +# run: | +# commit_message="${{ github.event.head_commit.message }}" +# is_release=${{ contains(github.event.head_commit.message, 'chore: release') }} +# echo "Does commit belong to a release: $is_release" +# echo "is-release=$is_release" >> $GITHUB_OUTPUT +# +# if [ "$is_release" = "true" ]; then +# release_info=$(echo "$commit_message" | sed -n 's/chore: release \(.*\) \(.*\)/\1 \2/p') +# crate_name=$(echo $release_info | cut -d' ' -f1) +# version=$(echo $release_info | cut -d' ' -f2) +# +# echo "Crate Name: $crate_name" +# echo "Version: $version" +# +# echo "crate-name=$crate_name" >> $GITHUB_OUTPUT +# echo "crate-version=$version" >> $GITHUB_OUTPUT +# else +# echo "Not a release commit. Skipping crate name and version extraction." +# fi +# +# +# - 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-amplifier +# submodules: recursive +# ref: ${{ steps.get-branch-name.outputs.branch }} +# +# +# - name: Import GPG key +# id: import_gpg +# uses: crazy-max/ghaction-import-gpg@v4 +# with: +# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} +# passphrase: ${{ secrets.GPG_PASSPHRASE }} +# +# +# - name: Compile all amplifier contracts +# id: compile-contracts +# run: | +# cd axelar-amplifier +# docker run --rm -v "$(pwd)":/code \ +# --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ +# --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ +# cosmwasm/optimizer:0.16.0 +# +# commit_hash=$(git rev-parse --short HEAD) +# cd .. +# mkdir -p ./artifacts/$commit_hash/ +# cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/ +# echo "wasm-directory=./artifacts" >> $GITHUB_OUTPUT +# +# +# - name: Prepare and sign release artifacts +# if: steps.check-release.outputs.is-release == 'true' +# id: prepare-release +# run: | +# cd ${{ steps.compile-contracts.outputs.wasm-directory }} +# crate_name="${{ steps.check-release.outputs.crate-name }}" +# crate_version="${{ steps.check-release.outputs.crate-version }}" +# wasm_file=$(find . -name "${crate_name//-/_}.wasm") +# checksum_file=$(find . -name "checksums.txt") +# +# if [ -z "$wasm_file" ]; then +# echo "Error: Could not find .wasm file for $crate_name" +# exit 1 +# fi +# +# mkdir -p "../release-artifacts" +# cp "$wasm_file" "../release-artifacts/${crate_name}.wasm" +# cp "$checksum_file" "../release-artifacts/" +# +# gpg --armor --detach-sign ../release-artifacts/${crate_name}.wasm +# gpg --armor --detach-sign ../release-artifacts/checksums.txt +# +# echo "release-artifacts-dir=./release-artifacts" >> $GITHUB_OUTPUT +# echo "r2-destination-dir=./releases/amplifier/${crate_name}/${crate_version}" >> $GITHUB_OUTPUT +# +# +# - uses: ryand56/r2-upload-action@latest +# if: steps.check-release.outputs.is-release == 'true' +# 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.prepare-release.outputs.release-artifacts-dir }} +# destination-dir: ${{ steps.prepare-release.outputs.r2-destination-dir }} +# +# +# - uses: ryand56/r2-upload-action@latest +# if: steps.check-release.outputs.is-release != 'true' +# 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.compile-contracts.outputs.wasm-directory }} +# destination-dir: ./pre-releases/ampd/contracts/ From 176d29c7305d555250e65c313daefe0ee8ab1793 Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 20:36:19 -0400 Subject: [PATCH 12/16] chore: test refs/tags path --- .github/workflows/build-contracts-and-push-to-r2.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index 9bbf3622d..f1ca99fdc 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -26,9 +26,8 @@ jobs: - name: Get tag id: get-tag run: | - echo "github ref name: ${{ github.ref_name }}" - echo "github event release tag name: ${{ github.event.release.tag_name }}" if [[ $GITHUB_REF == refs/tags/* ]]; then + echo "tag:${GITHUB_REF#refs/tags/}" echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT else echo "tag=" >> $GITHUB_OUTPUT From 0186c5b2e8efe7dc627d7e7dbde0264f16e2fbf3 Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 20:47:54 -0400 Subject: [PATCH 13/16] chore: test $GITHUB_REF --- .../workflows/build-contracts-and-push-to-r2.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index f1ca99fdc..2aa163109 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -26,12 +26,13 @@ jobs: - name: Get tag id: get-tag run: | - if [[ $GITHUB_REF == refs/tags/* ]]; then - echo "tag:${GITHUB_REF#refs/tags/}" - echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - else - echo "tag=" >> $GITHUB_OUTPUT - fi + echo "github_ref=$GITHUB_REF" +# if [[ $GITHUB_REF == refs/tags/* ]]; then +# echo "tag:${GITHUB_REF#refs/tags/}" +# echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT +# else +# echo "tag=" >> $GITHUB_OUTPUT +# fi # - name: Check for release information if present # id: check-release From 6e784919d6dc86e4dfbaa6646089959674ea58cf Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 21:01:28 -0400 Subject: [PATCH 14/16] chore: add on push with tag structure --- .../build-contracts-and-push-to-r2.yaml | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index 2aa163109..82329bda9 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -5,6 +5,8 @@ on: branches: - main - fix/push-releases-to-r2 + tags: + - '*-v[0-9]+.[0-9]+.[0-9]+' workflow_dispatch: inputs: branch: @@ -27,12 +29,36 @@ jobs: id: get-tag run: | echo "github_ref=$GITHUB_REF" -# if [[ $GITHUB_REF == refs/tags/* ]]; then -# echo "tag:${GITHUB_REF#refs/tags/}" -# echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT -# else -# echo "tag=" >> $GITHUB_OUTPUT -# fi + if [[ $GITHUB_REF == refs/tags/* ]]; then + echo "tag=${GITHUB_REF#refs/tags/}" + echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + else + echo "tag=" >> $GITHUB_OUTPUT + fi + + - name: Check for release information from tag + id: check-release + run: | + tag="${{ steps.get-tag.outputs.tag }}" + is_release="false" + + if [[ $tag =~ ^([a-zA-Z-]+)-v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then + is_release="true" + crate_name="${BASH_REMATCH[1]}" + crate_version="${BASH_REMATCH[2]}" + + echo "Is release: $is_release" + echo "Crate Name: $crate_name" + echo "Crate Version: $crate_version" + + echo "is-release=$is_release" >> $GITHUB_OUTPUT + echo "crate-name=$crate_name" >> $GITHUB_OUTPUT + echo "crate-version=$crate_version" >> $GITHUB_OUTPUT + else + echo "Is release: $is_release" + echo "Not a release tag. Skipping crate name and version extraction." + echo "is-release=$is_release" >> $GITHUB_OUTPUT + fi # - name: Check for release information if present # id: check-release From 74d4036f671b63962759752cfe4b3d2eab1c3378 Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 21:06:23 -0400 Subject: [PATCH 15/16] refactor: use tag instead of commit message to detect crate name and version --- .../build-contracts-and-push-to-r2.yaml | 205 ++++++++---------- 1 file changed, 91 insertions(+), 114 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index 82329bda9..b8752b948 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -4,7 +4,6 @@ on: push: branches: - main - - fix/push-releases-to-r2 tags: - '*-v[0-9]+.[0-9]+.[0-9]+' workflow_dispatch: @@ -60,116 +59,94 @@ jobs: echo "is-release=$is_release" >> $GITHUB_OUTPUT fi -# - name: Check for release information if present -# id: check-release -# run: | -# commit_message="${{ github.event.head_commit.message }}" -# is_release=${{ contains(github.event.head_commit.message, 'chore: release') }} -# echo "Does commit belong to a release: $is_release" -# echo "is-release=$is_release" >> $GITHUB_OUTPUT -# -# if [ "$is_release" = "true" ]; then -# release_info=$(echo "$commit_message" | sed -n 's/chore: release \(.*\) \(.*\)/\1 \2/p') -# crate_name=$(echo $release_info | cut -d' ' -f1) -# version=$(echo $release_info | cut -d' ' -f2) -# -# echo "Crate Name: $crate_name" -# echo "Version: $version" -# -# echo "crate-name=$crate_name" >> $GITHUB_OUTPUT -# echo "crate-version=$version" >> $GITHUB_OUTPUT -# else -# echo "Not a release commit. Skipping crate name and version extraction." -# fi -# -# -# - 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-amplifier -# submodules: recursive -# ref: ${{ steps.get-branch-name.outputs.branch }} -# -# -# - name: Import GPG key -# id: import_gpg -# uses: crazy-max/ghaction-import-gpg@v4 -# with: -# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} -# passphrase: ${{ secrets.GPG_PASSPHRASE }} -# -# -# - name: Compile all amplifier contracts -# id: compile-contracts -# run: | -# cd axelar-amplifier -# docker run --rm -v "$(pwd)":/code \ -# --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ -# --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ -# cosmwasm/optimizer:0.16.0 -# -# commit_hash=$(git rev-parse --short HEAD) -# cd .. -# mkdir -p ./artifacts/$commit_hash/ -# cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/ -# echo "wasm-directory=./artifacts" >> $GITHUB_OUTPUT -# -# -# - name: Prepare and sign release artifacts -# if: steps.check-release.outputs.is-release == 'true' -# id: prepare-release -# run: | -# cd ${{ steps.compile-contracts.outputs.wasm-directory }} -# crate_name="${{ steps.check-release.outputs.crate-name }}" -# crate_version="${{ steps.check-release.outputs.crate-version }}" -# wasm_file=$(find . -name "${crate_name//-/_}.wasm") -# checksum_file=$(find . -name "checksums.txt") -# -# if [ -z "$wasm_file" ]; then -# echo "Error: Could not find .wasm file for $crate_name" -# exit 1 -# fi -# -# mkdir -p "../release-artifacts" -# cp "$wasm_file" "../release-artifacts/${crate_name}.wasm" -# cp "$checksum_file" "../release-artifacts/" -# -# gpg --armor --detach-sign ../release-artifacts/${crate_name}.wasm -# gpg --armor --detach-sign ../release-artifacts/checksums.txt -# -# echo "release-artifacts-dir=./release-artifacts" >> $GITHUB_OUTPUT -# echo "r2-destination-dir=./releases/amplifier/${crate_name}/${crate_version}" >> $GITHUB_OUTPUT -# -# -# - uses: ryand56/r2-upload-action@latest -# if: steps.check-release.outputs.is-release == 'true' -# 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.prepare-release.outputs.release-artifacts-dir }} -# destination-dir: ${{ steps.prepare-release.outputs.r2-destination-dir }} -# -# -# - uses: ryand56/r2-upload-action@latest -# if: steps.check-release.outputs.is-release != 'true' -# 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.compile-contracts.outputs.wasm-directory }} -# destination-dir: ./pre-releases/ampd/contracts/ + + - 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-amplifier + submodules: recursive + ref: ${{ steps.get-branch-name.outputs.branch }} + + + - name: Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v4 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + + + - name: Compile all amplifier contracts + id: compile-contracts + run: | + cd axelar-amplifier + docker run --rm -v "$(pwd)":/code \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + cosmwasm/optimizer:0.16.0 + + commit_hash=$(git rev-parse --short HEAD) + cd .. + mkdir -p ./artifacts/$commit_hash/ + cp -R axelar-amplifier/artifacts/* ./artifacts/$commit_hash/ + echo "wasm-directory=./artifacts" >> $GITHUB_OUTPUT + + + - name: Prepare and sign release artifacts + if: steps.check-release.outputs.is-release == 'true' + id: prepare-release + run: | + cd ${{ steps.compile-contracts.outputs.wasm-directory }} + crate_name="${{ steps.check-release.outputs.crate-name }}" + crate_version="${{ steps.check-release.outputs.crate-version }}" + wasm_file=$(find . -name "${crate_name//-/_}.wasm") + checksum_file=$(find . -name "checksums.txt") + + if [ -z "$wasm_file" ]; then + echo "Error: Could not find .wasm file for $crate_name" + exit 1 + fi + + mkdir -p "../release-artifacts" + cp "$wasm_file" "../release-artifacts/${crate_name}.wasm" + cp "$checksum_file" "../release-artifacts/" + + gpg --armor --detach-sign ../release-artifacts/${crate_name}.wasm + gpg --armor --detach-sign ../release-artifacts/checksums.txt + + echo "release-artifacts-dir=./release-artifacts" >> $GITHUB_OUTPUT + echo "r2-destination-dir=./releases/amplifier/${crate_name}/${crate_version}" >> $GITHUB_OUTPUT + + + - uses: ryand56/r2-upload-action@latest + if: steps.check-release.outputs.is-release == 'true' + 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.prepare-release.outputs.release-artifacts-dir }} + destination-dir: ${{ steps.prepare-release.outputs.r2-destination-dir }} + + + - uses: ryand56/r2-upload-action@latest + if: steps.check-release.outputs.is-release != 'true' + 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.compile-contracts.outputs.wasm-directory }} + destination-dir: ./pre-releases/ampd/contracts/ From 29ffb587bfa2eadebc36c9b91f2bbef0660528e6 Mon Sep 17 00:00:00 2001 From: maancham Date: Wed, 24 Jul 2024 21:11:59 -0400 Subject: [PATCH 16/16] fix: update checkout step with correct logic and order of getting ref --- .../workflows/build-contracts-and-push-to-r2.yaml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-contracts-and-push-to-r2.yaml b/.github/workflows/build-contracts-and-push-to-r2.yaml index b8752b948..51d87aa49 100644 --- a/.github/workflows/build-contracts-and-push-to-r2.yaml +++ b/.github/workflows/build-contracts-and-push-to-r2.yaml @@ -60,15 +60,16 @@ jobs: fi - - name: Determine branch - id: get-branch-name + - name: Determine checkout ref + id: get-checkout-ref run: | - if [ "${{ github.event_name }}" == "push" ]; then - branch="main" + if [[ $GITHUB_REF == refs/tags/* ]]; then + echo "ref=$GITHUB_REF" >> $GITHUB_OUTPUT + elif [ "${{ github.event_name }}" == "push" ]; then + echo "ref=main" >> $GITHUB_OUTPUT else - branch="${{ inputs.branch }}" + echo "ref=${{ inputs.branch }}" >> $GITHUB_OUTPUT fi - echo "branch=$branch" >> $GITHUB_OUTPUT - name: Checkout code @@ -77,7 +78,7 @@ jobs: fetch-depth: "0" path: axelar-amplifier submodules: recursive - ref: ${{ steps.get-branch-name.outputs.branch }} + ref: ${{ steps.get-checkout-ref.outputs.ref }} - name: Import GPG key