Skip to content

Commit

Permalink
For master always build against release, dev instead against dev.
Browse files Browse the repository at this point in the history
  • Loading branch information
wargio committed Mar 19, 2024
1 parent 061d5bf commit 8be5271
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
24 changes: 19 additions & 5 deletions .ci-scripts/ci-build-linux.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#!/bin/bash
set -e

CI_BRANCH="$1"
CI_BRANCH="$1"
CI_JSDEC="$PWD"
CI_RZ_VERSION=$(curl -s GET https://api.github.com/repos/rizinorg/rizin/tags\?per_page\=1 | jq -r '.[].name')
CI_RZ_VERSION=$2

if [ "$2" != "dev" ]; then
# master branch always build against latest release of rizin
CI_RZ_VERSION=$(curl -s GET https://api.github.com/repos/rizinorg/rizin/tags\?per_page\=1 | jq -r '.[].name')
fi

echo "CI_BRANCH: $CI_BRANCH"
echo "CI_RZ_VERSION: $CI_RZ_VERSION"
Expand All @@ -12,11 +18,19 @@ echo "CI_JSDEC: $CI_JSDEC"
# avoid placing rizin in the same folder.
cd ..

# download the latest tagged rizin version and install it
wget -O "rizin.tar.xz" "https://github.com/rizinorg/rizin/releases/download/$CI_RZ_VERSION/rizin-src-$CI_RZ_VERSION.tar.xz"
tar xf "rizin.tar.xz"
cd "rizin-$CI_RZ_VERSION"
# download rizin
if [ "$CI_RZ_VERSION" == "dev" ]; then
# dev branch always build against latest commit of rizin
wget -O "rizin.tar.gz" "https://github.com/rizinorg/rizin/archive/refs/heads/dev.tar.gz"
tar xf "rizin.tar.gz"
else
# master branch always build against latest release of rizin
wget -O "rizin.tar.xz" "https://github.com/rizinorg/rizin/releases/download/$CI_RZ_VERSION/rizin-src-$CI_RZ_VERSION.tar.xz"
tar xf "rizin.tar.xz"
fi

# build rizin and install it.
cd "rizin-$CI_RZ_VERSION"
meson setup --buildtype=release -Denable_tests=false build
sudo ninja -C build install

Expand Down
22 changes: 14 additions & 8 deletions .ci-scripts/ci-rizin-dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@
import os

file_name = sys.argv[1]
latest = "master" if len(sys.argv) < 2 else sys.argv[2]

_, file_extension = os.path.splitext(file_name)
out_file = f"rizin{file_extension}"
print(file_name, out_file)

tags = None
with urllib.request.urlopen('https://api.github.com/repos/rizinorg/rizin/tags?per_page=1') as f:
tags = json.load(f)
latest = tags[0]['name']

url = f"https://github.com/rizinorg/rizin/releases/download/{latest}/{file_name}"
url = url.format(version=latest)
if latest != "dev":
# master branch always build against latest release of rizin
tags = None
with urllib.request.urlopen('https://api.github.com/repos/rizinorg/rizin/tags?per_page=1') as f:
tags = json.load(f)
latest = tags[0]['name']
url = f"https://github.com/rizinorg/rizin/releases/download/{latest}/{file_name}"
url = url.format(version=latest)
else:
# dev branch always build against latest commit of rizin
url = "https://github.com/rizinorg/rizin/archive/refs/heads/dev.zip"

print(f"Latest rizin tag: {latest}")
print(f"Using rizin branch: {latest}")
print(f"{url} as {out_file}")

urllib.request.urlretrieve(url, out_file)
6 changes: 3 additions & 3 deletions .github/workflows/build-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install dependencies
run: sudo apt -y install meson ninja-build
- name: Build & run the plugin
run: bash .ci-scripts/ci-build-linux.sh "${{ github.ref_name }}"
run: bash .ci-scripts/ci-build-linux.sh "${{ github.event.pull_request.base.ref || github.ref_name }}"

windows-64:
runs-on: windows-latest
Expand Down Expand Up @@ -52,8 +52,8 @@ jobs:
run: |
WORKDIR="$PWD"
cd ..
python "$WORKDIR/.ci-scripts/ci-rizin-dl.py" 'rizin-${{ matrix.release }}-{version}.zip'
unzip rizin.zip
python "$WORKDIR/.ci-scripts/ci-rizin-dl.py" 'rizin-${{ matrix.release }}-{version}.zip' '${{ github.event.pull_request.base.ref || github.ref_name }}'
unzip -q rizin.zip
rm *.zip
mv rizin* rizin
cd "$WORKDIR"
Expand Down

0 comments on commit 8be5271

Please sign in to comment.