Skip to content

Commit

Permalink
chore: test ci
Browse files Browse the repository at this point in the history
  • Loading branch information
aeweda committed Nov 13, 2024
1 parent ded83bb commit 3cbe6fd
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 61 deletions.
30 changes: 30 additions & 0 deletions .github/actions/build-bridge/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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
2 changes: 1 addition & 1 deletion .github/actions/build-helper/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build Helpers
description: "Builds & Parallelize Helper images for the compilation then archives them for next stage"

Inputs:
inputs:
imagename:
description: name of the image to tag & upload
required: true
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/build-linux/action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build Binaries
description: "Builds Linux Binaries"

Inputs:
inputs:
target:
description: Build target architecture
required: true
Expand Down
173 changes: 114 additions & 59 deletions .github/workflows/bridge.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,130 @@
name: Bridge

on:
workflow_run:
workflows: ["Release Tag"]
types: [completed]
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
environment: tags
if: ${{ github.event.workflow_run.conclusion == 'success' || inputs.force }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Protobuf
run: |
sudo apt install -y protobuf-compiler
protoc --version
- name: Build witnet-centralized-ethereum-bridge
run: |
cargo build -p witnet-centralized-ethereum-bridge --release
- name: Move file to outside docker ignored
run: |
cp target/release/witnet-centralized-ethereum-bridge ./
- name: Check Pre-release
run: |
TAG=${{ github.ref_name }}
if [[ "$TAG" =~ - ]]; then
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
- name: Building Docker Image
uses: ./.github/actions/build-helper
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
if: env.prerelease == 'false'


Failure:
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
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo '(Release Tag) workflow failed, EXITING!!!!' && exit 1
- 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
# steps:
# - name: Checkout
# uses: actions/checkout@v4

# - name: Login to Docker Container Registry
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

# - name: Build Base
# run: |
# 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/witnet-rust/Dockerfile --progress=plain --build-arg WITNET_VERSION=${{github.ref_name}} --platform linux/amd64,linux/arm64,linux/arm/v7 --tag witnet/witnet-rust:${{github.ref_name}} docker/witnet-rust --push --no-cache

# - name: Check Pre-release
# run: |
# TAG=${{ github.ref_name }}
# if [[ "$TAG" =~ - ]]; then
# echo "prerelease=true" >> $GITHUB_ENV
# else
# echo "prerelease=false" >> $GITHUB_ENV
# fi

# - name: Build Latest if not Pre-Release
# run: docker buildx build -f docker/witnet-rust/Dockerfile --progress=plain --build-arg WITNET_VERSION=latest --platform linux/amd64,linux/arm64,linux/arm/v7 --tag witnet/witnet-rust:latest docker/witnet-rust --push --no-cache
# if: env.prerelease == 'false'
1 change: 1 addition & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
tags:
- '*'
- '!*bridge*'

env:
CARGO_TERM_COLOR: always
Expand Down

0 comments on commit 3cbe6fd

Please sign in to comment.