Skip to content

Commit 465f1fd

Browse files
authored
Merge pull request #61 from restake/RES-1803
RES-1803: Accept target references
2 parents 1b1fab2 + 30aa9ef commit 465f1fd

File tree

2 files changed

+56
-26
lines changed

2 files changed

+56
-26
lines changed

.github/workflows/build.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ on:
55
inputs:
66
binary_version:
77
description: "Specify the version"
8-
required: true
8+
required: false
9+
binary_hash:
10+
description: "Specify the release hash"
11+
required: false
912
repository_name:
1013
description: "Specify the repository"
1114
required: true
@@ -17,6 +20,7 @@ on:
1720
- webhook
1821

1922
env:
23+
DEPOT_BINARY_HASH: "${{ inputs.binary_hash }}"
2024
DEPOT_BINARY_VERSION: "${{ inputs.binary_version }}"
2125
DEPOT_REPOSITORY_ORG: "${{ inputs.repository_org }}"
2226
DEPOT_REPOSITORY_NAME: "${{ inputs.repository_name }}"
@@ -114,16 +118,28 @@ jobs:
114118
name: "Setup builder"
115119
run: bash ./builders/${{ env.DEPOT_BUILDER }}/setup.sh
116120

117-
- id: "clone"
118-
name: "Clone protocol source"
121+
- id: "clone-tags"
122+
name: "Clone protocol source from tags"
119123
uses: "actions/checkout@v4"
124+
if: "${{ env.DEPOT_BINARY_VERSION != '' }}"
120125
with:
121126
repository: "${{ env.DEPOT_REPOSITORY_ORG }}/${{ env.DEPOT_REPOSITORY_NAME }}"
122127
fetch-tags: true
123128
path: "${{ env.DEPOT_PROJECT_NAME }}"
124129
ref: "refs/tags/${{ env.DEPOT_BINARY_VERSION }}"
125130
submodules: true
126131

132+
- id: "clone-ref"
133+
name: "Clone protocol source from specified reference"
134+
uses: "actions/checkout@v4"
135+
if: "${{ env.DEPOT_BINARY_HASH != '' }}"
136+
with:
137+
repository: "${{ env.DEPOT_REPOSITORY_ORG }}/${{ env.DEPOT_REPOSITORY_NAME }}"
138+
path: "${{ env.DEPOT_PROJECT_NAME }}"
139+
ref: "${{ env.DEPOT_BINARY_HASH }}"
140+
fetch-depth: 1
141+
submodules: true
142+
127143
- id: "apply-patches"
128144
name: "Apply patches"
129145
if: ${{ needs.outputs.outputs.depot_patches == 'true' }}
@@ -182,10 +198,12 @@ jobs:
182198
run: |
183199
set -euo pipefail
184200
201+
VERSION="${DEPOT_BINARY_VERSION:-SHA-$DEPOT_BINARY_HASH}"
202+
185203
for file in binaries/*; do
186204
if [ -f "$file" ]; then
187205
filename=$(basename "$file")
188-
directory="${{ needs.outputs.outputs.depot_purpose }}/${{ needs.outputs.outputs.depot_project_name }}/${{ env.DEPOT_BINARY_VERSION }}"
206+
directory="${{ needs.outputs.outputs.depot_purpose }}/${{ needs.outputs.outputs.depot_project_name }}/${VERSION}"
189207
190208
rclone --config="rclone.conf" copy "$file" "r2:${{ env.DEPOT_BUCKET_NAME }}/${directory}"
191209
@@ -219,7 +237,10 @@ jobs:
219237
name: "Set environment variables for Docker"
220238
run: |
221239
echo "DEPOT_PROJECT_NAME=${{ needs.outputs.outputs.depot_project_name }}" >> "${GITHUB_ENV}"
222-
echo "DEPOT_BINARY_VERSION=${{ env.DEPOT_BINARY_VERSION }}" >> "${GITHUB_ENV}"
240+
241+
VERSION="${DEPOT_BINARY_VERSION:-$DEPOT_BINARY_HASH}"
242+
243+
echo "DEPOT_BINARY_VERSION=${VERSION}" >> "${GITHUB_ENV}"
223244
224245
project_dockerfile="docker/${{ needs.outputs.outputs.depot_project_name }}.Dockerfile"
225246
if [ -f "${project_dockerfile}" ]; then
@@ -296,11 +317,6 @@ jobs:
296317
name: "Set project name to envvar"
297318
run: echo "DEPOT_PROJECT_NAME=${{ needs.outputs.outputs.depot_project_name }}" >> "${GITHUB_ENV}"
298319

299-
- id: "envvar-test"
300-
run: |
301-
echo ${{ env.DEPOT_PROJECT_NAME }}
302-
echo ${{ env.DEPOT_BINARY_VERSION }}
303-
304320
- id: "checkout"
305321
name: "Checkout code"
306322
uses: actions/checkout@v4

scripts/sui/build.sh

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,38 @@
22
set -euo pipefail
33

44
cd "${DEPOT_PROJECT_NAME}"
5-
mkdir bin
65

7-
export CARGO_BUILD_TARGET="x86_64-unknown-linux-gnu"
8-
export CARGO_INCREMENTAL="0"
9-
10-
# Replace literal '\n' with actual newlines for proper splitting
11-
binaries=$(echo -e "${DEPOT_BINARY_BUILD_NAME}")
12-
13-
args=()
14-
15-
while IFS= read -r binary; do
6+
if [[ -n "${DEPOT_BINARY_HASH:-}" ]]; then
7+
echo "Building binaries from specific hash: ${DEPOT_BINARY_HASH}"
8+
9+
mkdir -p bin
10+
export CARGO_BUILD_TARGET="x86_64-unknown-linux-gnu"
11+
export CARGO_INCREMENTAL="0"
12+
13+
cargo build --release --bin sui --bin sui-bridge-cli --bin sui-bridge
14+
15+
build_binaries="$(deno run --allow-read --allow-env ../utils/binaries.ts)"
16+
echo "${build_binaries}" | jq -r 'to_entries[] | "\(.key) \(.value)"' | while read -r binary path; do
17+
if [ -f "target/${CARGO_BUILD_TARGET}/release/${binary}" ]; then
18+
mv -v "target/${CARGO_BUILD_TARGET}/release/${binary}" "${path}"
19+
fi
20+
done
21+
else
22+
echo "Building binaries from tags..."
23+
mkdir -p bin
24+
export CARGO_BUILD_TARGET="x86_64-unknown-linux-gnu"
25+
export CARGO_INCREMENTAL="0"
26+
27+
binaries=$(echo -e "${DEPOT_BINARY_BUILD_NAME}")
28+
args=()
29+
while IFS= read -r binary; do
1630
args+=(--bin "${binary}")
17-
done <<< "${binaries}"
18-
19-
cargo build --release "${args[@]}"
31+
done <<< "${binaries}"
2032

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

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

0 commit comments

Comments
 (0)