Skip to content

Commit

Permalink
RES-1803: Accept target references
Browse files Browse the repository at this point in the history
  • Loading branch information
hansaaviksoo committed Nov 25, 2024
1 parent 95cb50d commit e791d9e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 23 deletions.
35 changes: 25 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
inputs:
binary_version:
description: "Specify the version"
required: true
required: false
binary_hash:
description: "Specify the release hash"
required: false
repository_name:
description: "Specify the repository"
required: true
Expand All @@ -17,6 +20,7 @@ on:
- webhook

env:
DEPOT_BINARY_HASH: "${{ inputs.binary_hash }}"
DEPOT_BINARY_VERSION: "${{ inputs.binary_version }}"
DEPOT_REPOSITORY_ORG: "${{ inputs.repository_org }}"
DEPOT_REPOSITORY_NAME: "${{ inputs.repository_name }}"
Expand Down Expand Up @@ -114,16 +118,27 @@ jobs:
name: "Setup builder"
run: bash ./builders/${{ env.DEPOT_BUILDER }}/setup.sh

- id: "clone"
name: "Clone protocol source"
- id: "clone-tags"
name: "Clone protocol source from tags"
uses: "actions/checkout@v4"
if: "${{ env.DEPOT_BINARY_VERSION != '' }}"
with:
repository: "${{ env.DEPOT_REPOSITORY_ORG }}/${{ env.DEPOT_REPOSITORY_NAME }}"
fetch-tags: true
path: "${{ env.DEPOT_PROJECT_NAME }}"
ref: "refs/tags/${{ env.DEPOT_BINARY_VERSION }}"
submodules: true

- id: "clone-ref"
name: "Clone protocol source from specified reference"
uses: "actions/checkout@v4"
if: "${{ env.DEPOT_BINARY_HASH != '' }}"
with:
repository: "${{ env.DEPOT_REPOSITORY_ORG }}/${{ env.DEPOT_REPOSITORY_NAME }}"
path: "${{ env.DEPOT_PROJECT_NAME }}"
ref: "refs/${{ env.DEPOT_BINARY_HASH }}"
submodules: true

- id: "apply-patches"
name: "Apply patches"
if: ${{ needs.outputs.outputs.depot_patches == 'true' }}
Expand Down Expand Up @@ -182,10 +197,12 @@ jobs:
run: |
set -euo pipefail
VERSION="${DEPOT_BINARY_VERSION:-$DEPOT_BINARY_HASH}"
for file in binaries/*; do
if [ -f "$file" ]; then
filename=$(basename "$file")
directory="${{ needs.outputs.outputs.depot_purpose }}/${{ needs.outputs.outputs.depot_project_name }}/${{ env.DEPOT_BINARY_VERSION }}"
directory="${{ needs.outputs.outputs.depot_purpose }}/${{ needs.outputs.outputs.depot_project_name }}/${VERSION}"
rclone --config="rclone.conf" copy "$file" "r2:${{ env.DEPOT_BUCKET_NAME }}/${directory}"
Expand Down Expand Up @@ -219,7 +236,10 @@ jobs:
name: "Set environment variables for Docker"
run: |
echo "DEPOT_PROJECT_NAME=${{ needs.outputs.outputs.depot_project_name }}" >> "${GITHUB_ENV}"
echo "DEPOT_BINARY_VERSION=${{ env.DEPOT_BINARY_VERSION }}" >> "${GITHUB_ENV}"
VERSION="${DEPOT_BINARY_VERSION:-$DEPOT_BINARY_HASH}"
echo "DEPOT_BINARY_VERSION=${VERSION}" >> "${GITHUB_ENV}"
project_dockerfile="docker/${{ needs.outputs.outputs.depot_project_name }}.Dockerfile"
if [ -f "${project_dockerfile}" ]; then
Expand Down Expand Up @@ -296,11 +316,6 @@ jobs:
name: "Set project name to envvar"
run: echo "DEPOT_PROJECT_NAME=${{ needs.outputs.outputs.depot_project_name }}" >> "${GITHUB_ENV}"

- id: "envvar-test"
run: |
echo ${{ env.DEPOT_PROJECT_NAME }}
echo ${{ env.DEPOT_BINARY_VERSION }}
- id: "checkout"
name: "Checkout code"
uses: actions/checkout@v4
Expand Down
41 changes: 28 additions & 13 deletions scripts/sui/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,39 @@
set -euo pipefail

cd "${DEPOT_PROJECT_NAME}"
mkdir bin

export CARGO_BUILD_TARGET="x86_64-unknown-linux-gnu"
export CARGO_INCREMENTAL="0"
if [[ -n "${DEPOT_BINARY_HASH:-}" ]]; then
echo "Building binaries from specific hash: ${DEPOT_BINARY_HASH}"

# Replace literal '\n' with actual newlines for proper splitting
binaries=$(echo -e "${DEPOT_BINARY_BUILD_NAME}")
git fetch --depth=1 origin "${DEPOT_BINARY_HASH}"
git checkout "${DEPOT_BINARY_HASH}"

args=()
mkdir -p bin
export CARGO_BUILD_TARGET="x86_64-unknown-linux-gnu"
export CARGO_INCREMENTAL="0"

while IFS= read -r binary; do
args+=(--bin "${binary}")
done <<< "${binaries}"
cargo build --release sui sui-bridge-cli sui-bridge

cargo build --release "${args[@]}"
build_binaries="$(deno run --allow-read --allow-env ../utils/binaries.ts)"
echo "${build_binaries}" | jq -r 'to_entries[] | "\(.key) \(.value)"' | while read -r binary path; do
mv -v "target/${CARGO_BUILD_TARGET}/release/${binary}" "${path}"
done
else
echo "Building binaries from tags..."
mkdir -p bin
export CARGO_BUILD_TARGET="x86_64-unknown-linux-gnu"
export CARGO_INCREMENTAL="0"

binaries=$(echo -e "${DEPOT_BINARY_BUILD_NAME}")
args=()
while IFS= read -r binary; do
args+=(--bin "${binary}")
done <<< "${binaries}"

build_binaries="$(deno run --allow-read --allow-env ../utils/binaries.ts)"
cargo build --release "${args[@]}"

echo "${build_binaries}" | jq -r 'to_entries[] | "\(.key) \(.value)"' | while read -r binary path; do
build_binaries="$(deno run --allow-read --allow-env ../utils/binaries.ts)"
echo "${build_binaries}" | jq -r 'to_entries[] | "\(.key) \(.value)"' | while read -r binary path; do
mv -v "target/${CARGO_BUILD_TARGET}/release/${binary}" "${path}"
done
done
fi

0 comments on commit e791d9e

Please sign in to comment.