From 917889fd3a9caa8ccf55c052803d39215e6ede10 Mon Sep 17 00:00:00 2001 From: aeweda Date: Wed, 13 Nov 2024 19:38:20 +0400 Subject: [PATCH 1/5] chore: update docker image --- docker/bridge/Dockerfile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docker/bridge/Dockerfile b/docker/bridge/Dockerfile index dcebe0d32..ce00751e8 100644 --- a/docker/bridge/Dockerfile +++ b/docker/bridge/Dockerfile @@ -1,5 +1,22 @@ FROM witnet/witnet-rust:latest -COPY ./witnet-centralized-ethereum-bridge / +ARG TARGETPLATFORM + +# Use a conditional COPY command based on the target platform +COPY witnet-centralized-ethereum-bridge-x86_64-unknown-linux-gnu / +COPY witnet-centralized-ethereum-bridge-aarch64-unknown-linux-gnu / + +RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + echo "Current platform linux/amd64"; \ + mv /witnet-centralized-ethereum-bridge-x86_64-unknown-linux-gnu /witnet-centralized-ethereum-bridge; \ + rm /witnet-centralized-ethereum-bridge-aarch64-unknown-linux-gnu; \ + elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ + echo "Current platform linux/arm64"; \ + mv /witnet-centralized-ethereum-bridge-aarch64-unknown-linux-gnu /witnet-centralized-ethereum-bridge; \ + rm /witnet-centralized-ethereum-bridge-x86_64-unknown-linux-gnu; \ + else \ + echo "Unsupported platform: $TARGETPLATFORM"; \ + exit 1; \ + fi ENTRYPOINT ["/witnet-centralized-ethereum-bridge", "--env"] \ No newline at end of file From a2eae40d159a2d4c92f6afc09059519c8acf3b82 Mon Sep 17 00:00:00 2001 From: aeweda Date: Wed, 13 Nov 2024 19:38:36 +0400 Subject: [PATCH 2/5] chore: update action & prevent bridge tags trigger --- .github/workflows/master.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index cbaab5a7e..94dc3cd74 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -4,6 +4,7 @@ on: push: tags: - '*' + - '!*bridge*' env: CARGO_TERM_COLOR: always @@ -201,7 +202,7 @@ jobs: - name: Import GPG key id: import_gpg - uses: crazy-max/ghaction-import-gpg@v5 + uses: crazy-max/ghaction-import-gpg@v6 with: gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} passphrase: ${{ secrets.GPG_PASSPHRASE }} From a5bfaea39a48289f312307ee7471896f31810187 Mon Sep 17 00:00:00 2001 From: aeweda Date: Wed, 13 Nov 2024 19:38:50 +0400 Subject: [PATCH 3/5] ci: add helper action for building bridge --- .github/actions/build-bridge/action.yml | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/actions/build-bridge/action.yml diff --git a/.github/actions/build-bridge/action.yml b/.github/actions/build-bridge/action.yml new file mode 100644 index 000000000..8583f14f0 --- /dev/null +++ b/.github/actions/build-bridge/action.yml @@ -0,0 +1,29 @@ +name: Build Binaries +description: "Builds Linux Binaries" + +inputs: + target: + description: Build target architecture + required: true + +runs: + using: "composite" + steps: + # Download Helper Image built in the previous jobs + - name: Downloading helper Image + uses: ishworkh/container-image-artifact-download@v2.0.0 + with: + image: "witnet-rust/${{ inputs.target }}:latest" + + - name: Export Vars + shell: bash + run: | + echo PWD=`pwd` >> $GITHUB_ENV + echo TARGET=${{ inputs.target }} >> $GITHUB_ENV + - name: Build Binary + shell: bash + run: docker run -v `pwd`:/project:ro -v `pwd`/target:/target -v ~/.cargo:/root/.cargo -w /project -i witnet-rust/$TARGET bash -c "cargo build --release --target=$TARGET --target-dir=/target -p witnet-centralized-ethereum-bridge" + + - name: List Directory + shell: bash + run: ls -lsa ./target/${{ inputs.target }}/release From 6d54332c02f1b0ccd07462df74e4125fa1e000ac Mon Sep 17 00:00:00 2001 From: aeweda Date: Wed, 13 Nov 2024 19:39:10 +0400 Subject: [PATCH 4/5] ci: revamp bridge flow --- .github/workflows/bridge.yml | 168 ++++++++++++++++++++++++++--------- 1 file changed, 125 insertions(+), 43 deletions(-) diff --git a/.github/workflows/bridge.yml b/.github/workflows/bridge.yml index eb098c80b..78b960e98 100644 --- a/.github/workflows/bridge.yml +++ b/.github/workflows/bridge.yml @@ -1,38 +1,145 @@ name: Bridge on: - workflow_dispatch: - inputs: - force: - description: 'Force execution of this action' - type: boolean - required: false - default: true + push: + tags: + - '*-bridge*' env: CARGO_TERM_COLOR: always jobs: - Bridge: +#?####################################################################################################?# +#? ?# +#? Build Helper Images ?# +#? ?# +#?####################################################################################################?# + aarch64: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Building Docker Image + uses: ./.github/actions/build-helper + with: + imagename: aarch64-unknown-linux-gnu + + x86_64: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Building Docker Image + uses: ./.github/actions/build-helper + with: + imagename: x86_64-unknown-linux-gnu + +#?####################################################################################################?# +#? ?# +#? Build Releases ?# +#? ?# +#?####################################################################################################?# + + Build_aarch64: + needs: [aarch64] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Building aarch64 Binary + uses: ./.github/actions/build-bridge + with: + target: aarch64-unknown-linux-gnu + + - name: see path + run: cd target && tree + + - name: Upload Build + uses: actions/upload-artifact@v4 + with: + name: aarch64-release + path: | + target/aarch64-unknown-linux-gnu/release/witnet-centralized-ethereum-bridge + + Build_x86_64: + needs: [x86_64] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Building x86_64 Binary + uses: ./.github/actions/build-bridge + with: + target: x86_64-unknown-linux-gnu + + - name: see path + run: cd target && tree + + - name: Upload Build + uses: actions/upload-artifact@v4 + with: + name: x86_64-release + path: | + target/x86_64-unknown-linux-gnu/release/witnet-centralized-ethereum-bridge + + +#?####################################################################################################?# +#? ?# +#? Sign & Publish ?# +#? ?# +#?####################################################################################################?# + Publish: + needs: [Build_aarch64, Build_x86_64] runs-on: ubuntu-latest environment: tags - if: ${{ github.event.workflow_run.conclusion == 'success' || inputs.force }} steps: - name: Checkout uses: actions/checkout@v4 - - name: Install Protobuf + - name: Login to Docker Container Registry + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Download aarch64 Build + uses: actions/download-artifact@v4 + with: + name: aarch64-release + path: all-releases/aarch64/ + + - name: Download x86_64 Build + uses: actions/download-artifact@v4 + with: + name: x86_64-release + path: all-releases/x86_64/ + + - name: Prepare aarch64 run: | - sudo apt install -y protobuf-compiler - protoc --version + chmod +x ./all-releases/aarch64/witnet-centralized-ethereum-bridge + mv all-releases/aarch64/witnet-centralized-ethereum-bridge docker/bridge/witnet-centralized-ethereum-bridge-aarch64-unknown-linux-gnu - - name: Build witnet-centralized-ethereum-bridge + - name: Prepare x86_64 run: | - cargo build -p witnet-centralized-ethereum-bridge --release + chmod +x ./all-releases/x86_64/witnet-centralized-ethereum-bridge + mv all-releases/x86_64/witnet-centralized-ethereum-bridge docker/bridge/witnet-centralized-ethereum-bridge-x86_64-unknown-linux-gnu + + - name: List binaries + run: tree docker - - name: Move file to outside docker ignored + - name: Build Base run: | - cp target/release/witnet-centralized-ethereum-bridge ./ + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + docker buildx create --name multiarch --driver docker-container --use + docker buildx inspect --bootstrap + + # Build Docker images (Latest & TAG) + - name: Build TAG + run: docker buildx build -f docker/bridge/Dockerfile --progress=plain --platform linux/amd64,linux/arm64 --tag witnet/witnet-centralized-ethereum-bridge:${{github.ref_name}} docker/bridge - name: Check Pre-release run: | @@ -41,32 +148,7 @@ jobs: echo "prerelease=true" >> $GITHUB_ENV else echo "prerelease=false" >> $GITHUB_ENV - fi - - - name: Set Version - run: | - echo VERNUM=$(sed -nE 's/version\s?=\s?"([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.]+)?)"/\1/p' ./bridges/centralized-ethereum/Cargo.toml | head -1) >> $GITHUB_ENV - - - name: Login to Docker hub Registry - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build & Push Tag Image - run: | - docker build -t witnet/witnet-centralized-ethereum-bridge:"$VERNUM" -f ./docker/bridge/Dockerfile . - docker push witnet/witnet-centralized-ethereum-bridge:"$VERNUM" - - - name: Build & Push Latest if not Pre-Release - run: | - docker build -t witnet/witnet-centralized-ethereum-bridge:latest -f ./docker/bridge/Dockerfile . - docker push witnet/witnet-centralized-ethereum-bridge:latest + - name: Build Latest if not Pre-Release if: env.prerelease == 'false' - - - Failure: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'failure' }} - steps: - - run: echo '(Release Tag) workflow failed, EXITING!!!!' && exit 1 + run: docker buildx build -f docker/bridge/Dockerfile --progress=plain --platform linux/amd64,linux/arm64 --tag witnet/witnet-centralized-ethereum-bridge:latest docker/bridge --push --no-cache \ No newline at end of file From 8c37ffc9a9364740bacb809fb199975d67a4f28a Mon Sep 17 00:00:00 2001 From: aeweda Date: Wed, 13 Nov 2024 20:18:18 +0400 Subject: [PATCH 5/5] chore: prune tag for docker image --- .github/workflows/bridge.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bridge.yml b/.github/workflows/bridge.yml index 78b960e98..6df4d6bfc 100644 --- a/.github/workflows/bridge.yml +++ b/.github/workflows/bridge.yml @@ -139,12 +139,14 @@ jobs: # Build Docker images (Latest & TAG) - name: Build TAG - run: docker buildx build -f docker/bridge/Dockerfile --progress=plain --platform linux/amd64,linux/arm64 --tag witnet/witnet-centralized-ethereum-bridge:${{github.ref_name}} docker/bridge + run: | + PRUNED_TAG=$(echo "${{github.ref_name}}" | sed 's/-bridge//') + docker buildx build -f docker/bridge/Dockerfile --progress=plain --platform linux/amd64,linux/arm64 --tag witnet/witnet-centralized-ethereum-bridge:$PRUNED_TAG docker/bridge - name: Check Pre-release run: | TAG=${{ github.ref_name }} - if [[ "$TAG" =~ - ]]; then + if [[ "$TAG" =~ -rc ]]; then echo "prerelease=true" >> $GITHUB_ENV else echo "prerelease=false" >> $GITHUB_ENV