updated workflow step
This commit is contained in:
@@ -326,90 +326,41 @@ jobs:
|
||||
env:
|
||||
DISTRO_TYPE: rhel
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ghcr.io/jmr-dev/android-file-handler-adb:v0.1.0
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.inputs.branch || github.head_ref || github.ref }}
|
||||
|
||||
- name: Update OS and install Docker
|
||||
- name: Build RHEL package
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo apt-get update
|
||||
# Remove possible conflicting containerd packages that can block docker.io installation
|
||||
sudo apt-get remove -y --purge containerd containerd.io || true
|
||||
sudo apt-get autoremove -y || true
|
||||
# Try installing docker.io from distro packages
|
||||
if ! sudo apt-get install -y --no-install-recommends ca-certificates curl gnupg lsb-release docker.io git build-essential; then
|
||||
echo "apt install docker.io failed; falling back to Docker convenience script"
|
||||
# Fallback: use Docker's official convenience script
|
||||
curl -fsSL https://get.docker.com | sudo sh
|
||||
fi
|
||||
sudo usermod -aG docker $USER || true
|
||||
export CI_CD=true
|
||||
export DISTRO_TYPE=rhel
|
||||
poetry install --no-interaction
|
||||
poetry run python scripts/build_package_linux.py
|
||||
|
||||
- name: Pull Fedora container image
|
||||
run: |
|
||||
docker pull fedora:latest
|
||||
|
||||
- name: Start Fedora container (background) and mount repo
|
||||
run: |
|
||||
# Run container with workspace mounted
|
||||
docker run -d --name rhel-build -v "$PWD":/workspace -w /workspace fedora:latest sleep infinity
|
||||
|
||||
- name: Prepare container build environment (dnf, pyenv, python, poetry, fpm)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Update the Fedora image and install build deps
|
||||
docker exec rhel-build bash -lc "dnf -y update && dnf -y install gcc make zlib-devel bzip2 bzip2-devel readline-devel sqlite-devel openssl-devel libffi-devel wget tar git curl ruby rubygems rpm-build redhat-rpm-config gcc-c++ patch which xz-devel"
|
||||
|
||||
# Install pyenv into the container (if not present)
|
||||
docker exec rhel-build bash -lc "[ -d \"/root/.pyenv\" ] || git clone https://github.com/pyenv/pyenv.git /root/.pyenv && mkdir -p /root/.pyenv/plugins && [ -d \"/root/.pyenv/plugins/python-build\" ] || git clone https://github.com/pyenv/pyenv-build.git /root/.pyenv/plugins/python-build"
|
||||
|
||||
# Install Python 3.12 via pyenv and set global using explicit pyenv binary path
|
||||
# Use single quotes so $PYENV_ROOT and $PATH are expanded inside the container's shell
|
||||
docker exec rhel-build bash -lc 'export PYENV_ROOT="/root/.pyenv"; export PATH="$PYENV_ROOT/bin:$PATH"; /root/.pyenv/bin/pyenv install -s 3.12.0; /root/.pyenv/bin/pyenv global 3.12.0; /root/.pyenv/bin/pyenv rehash'
|
||||
|
||||
# Install Poetry inside the container using the official installer (install to /root/.local/bin)
|
||||
# Use single quotes so PATH is evaluated inside the container shell rather than the runner
|
||||
docker exec rhel-build bash -lc 'export PATH="/root/.pyenv/shims:/root/.pyenv/bin:$PATH"; curl -sSL https://install.python-poetry.org | python3 - --yes'
|
||||
|
||||
# Verify Poetry is available via explicit path if not on PATH
|
||||
docker exec rhel-build bash -lc "/root/.local/bin/poetry --version || echo 'Poetry not found in /root/.local/bin'"
|
||||
|
||||
# Install fpm (Ruby gem) and ensure rpm build tools exist
|
||||
docker exec rhel-build bash -lc "dnf -y install ruby rubygems make && gem install --no-document -v \"${FPM_VERSION}\" fpm"
|
||||
|
||||
- name: Build inside container using Poetry
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Use poetry inside the container to build package layouts. Use explicit paths so the runner shell
|
||||
# doesn't expand $HOME; expansion should occur inside the container.
|
||||
docker exec rhel-build bash -lc 'export PATH="/root/.local/bin:/root/.pyenv/shims:/root/.pyenv/bin:$PATH"; export CI_CD=true; export DISTRO_TYPE=rhel; cd /workspace && /root/.local/bin/poetry install --no-interaction && /root/.local/bin/poetry run python scripts/build_package_linux.py'
|
||||
|
||||
- name: Package RHEL (fpm) inside container
|
||||
- name: Package RHEL (fpm)
|
||||
shell: bash
|
||||
run: |
|
||||
# Run the entire packaging flow inside the Fedora container so Poetry, PATH and arrays are evaluated in-container.
|
||||
docker exec rhel-build bash -lc '
|
||||
set -euo pipefail
|
||||
VERSION="$(/root/.local/bin/poetry version -s)"
|
||||
PKG_DIR="pkg_dist_rhel"
|
||||
mkdir -p dist || true
|
||||
echo "Packaging from $PKG_DIR (version=$VERSION)"
|
||||
ls -la "$PKG_DIR" || true
|
||||
set -euo pipefail
|
||||
VERSION="$(poetry version -s)"
|
||||
PKG_DIR="pkg_dist_rhel"
|
||||
mkdir -p dist
|
||||
echo "Packaging from $PKG_DIR (version=$VERSION)"
|
||||
ls -la "$PKG_DIR" || true
|
||||
|
||||
ICON_PATH="$PKG_DIR/usr/share/icons/hicolor/256x256/apps/android-file-handler.png"
|
||||
PKG_ITEMS=( "usr/bin/android-file-handler" "usr/share/applications/android-file-handler.desktop" )
|
||||
if [ -f "$ICON_PATH" ]; then
|
||||
PKG_ITEMS+=( "usr/share/icons/hicolor/256x256/apps/android-file-handler.png" )
|
||||
else
|
||||
echo "Note: icon not present, packaging without icon"
|
||||
fi
|
||||
ICON_PATH="$PKG_DIR/usr/share/icons/hicolor/256x256/apps/android-file-handler.png"
|
||||
PKG_ITEMS=( "usr/bin/android-file-handler" "usr/share/applications/android-file-handler.desktop" )
|
||||
if [ -f "$ICON_PATH" ]; then
|
||||
PKG_ITEMS+=( "usr/share/icons/hicolor/256x256/apps/android-file-handler.png" )
|
||||
else
|
||||
echo "Note: icon not present, packaging without icon"
|
||||
fi
|
||||
|
||||
# Run fpm inside the container to produce an RPM
|
||||
cd /workspace
|
||||
exec fpm -s dir -t rpm -n android-file-handler -v "$VERSION" --architecture x86_64 --prefix /usr/bin --after-install scripts/rhel_postinst.sh -p "dist/android-file-handler-${VERSION}.x86_64.rpm" -C "$PKG_DIR" "${PKG_ITEMS[@]}"
|
||||
'
|
||||
fpm -s dir -t rpm -n android-file-handler -v "$VERSION" --architecture x86_64 --prefix /usr/bin --after-install scripts/rhel_postinst.sh -p "dist/android-file-handler-${VERSION}.x86_64.rpm" -C "$PKG_DIR" "${PKG_ITEMS[@]}"
|
||||
|
||||
- name: Upload RHEL artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
|
||||
Reference in New Issue
Block a user