fix action build package (#115)

This commit is contained in:
Max Ivan
2025-03-01 22:14:13 +03:00
committed by GitHub
parent 6171a90b6e
commit 1bc4b98a8c

View File

@@ -40,6 +40,9 @@ jobs:
with:
fetch-depth: 1000
- name: Gather build summary
id: build-info
env:
MANUAL_INPUT_PACKAGES: ${{ github.event.inputs.packages }}
run: |
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
BASE_COMMIT=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH")
@@ -70,19 +73,11 @@ jobs:
# Forces CI to cancel current build with status 'passed'
if grep -qiP '^\s*%ci:no-build\s*$' <(git log --format="%B" -n 1 "HEAD"); then
tar cf artifacts/pkgs-${{ matrix.target_arch }}.tar pkgs
echo "docker-build=true" >> $GITHUB_OUTPUT
echo "[!] Force exiting as tag '%ci:no-build' was applied to HEAD commit message."
exit 0
fi
# Build local Docker image if setup scripts were changed.
# Useful for pull requests submitting changes for both build environment and packages.
if grep -qP '^scripts/(Dockerfile|properties\.sh|setup-android-sdk\.sh|setup-ubuntu\.sh)$' <<< "$CHANGED_FILES"; then
echo "Detected changes for environment setup scripts. Building custom Docker image now."
cd ./scripts
docker build -t ghcr.io/termux/package-builder:latest .
cd ..
fi
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
# Parse changed files and identify new packages and deleted packages.
@@ -117,7 +112,10 @@ jobs:
done<<<${CHANGED_FILES}
done
else
for pkg in ${{ github.event.inputs.packages }}; do
# Ensure MANUAL_INPUT_PACKAGES is newline free, and put it
# into an array
read -a PACKAGES <<< "${MANUAL_INPUT_PACKAGES//$'\n'/ }"
for pkg in "${PACKAGES[@]}"; do
repo_paths=$(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json)
found=false
for repo_path in $repo_paths; do
@@ -153,6 +151,34 @@ jobs:
fi
done
declare -a packages
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
if [ -f ./built_${repo}_packages.txt ]; then
packages="$packages $(cat ./built_${repo}_packages.txt | tr '\n' ' ')"
fi
done
docker='true'
[ -n "$packages" ] && if grep -qP "(^|\\s)${packages// /($|\\s)|(^|\\s)}($|\\s)" ./scripts/big-pkgs.list; then
docker='false'
fi
echo "docker-build=$docker" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
# Build local Docker image if setup scripts were changed.
# Useful for pull requests submitting changes for both build environment and packages.
if grep -qP '^scripts/(Dockerfile|properties\.sh|setup-android-sdk\.sh|setup-ubuntu\.sh)$' <<< "$CHANGED_FILES"; then
echo "Detected changes for environment setup scripts. Building custom Docker image now."
if [ $docker == 'false' ]; then
echo "Skipping due to building large packages."
exit 0
fi
cd ./scripts
docker build -t ghcr.io/termux/package-builder:latest .
cd ..
fi
fi
- name: Lint packages
run: |
declare -a package_recipes
@@ -167,46 +193,44 @@ jobs:
./scripts/lint-packages.sh $package_recipes
fi
- name: Free additional disk space (if necessary)
- name: Free additional disk space (if needed)
env:
DOCKER_BUILD: ${{ steps.build-info.outputs.docker-build }}
run: |
declare -a packages
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
if [ -f ./built_${repo}_packages.txt ]; then
packages="$packages $(cat ./built_${repo}_packages.txt | tr '\n' ' ')"
fi
done
if [ ! -z "$packages" ]; then
if grep -qP "(^|\\s)${packages// /($|\\s)|(^|\\s)}($|\\s)" ./scripts/big-pkgs.list; then
./scripts/setup-ubuntu.sh
sudo apt install ninja-build
sudo apt purge -yq $(dpkg -l | grep '^ii' | awk '{ print $2 }' | grep -P '(aspnetcore|cabal-|dotnet-|ghc-|libmono|mongodb-|mysql-|php)') \
firefox google-chrome-stable microsoft-edge-stable mono-devel mono-runtime-common monodoc-manual ruby
sudo apt autoremove -yq
sudo apt clean
sudo rm -fr /opt/hostedtoolcache /usr/lib/node_modules /usr/share/dotnet /usr/share/swift
fi
if [ "$DOCKER_BUILD" == 'false' ]; then
./scripts/setup-ubuntu.sh
sudo apt install ninja-build
sudo apt purge -yq $(dpkg -l | grep '^ii' | awk '{ print $2 }' | grep -P '(aspnetcore|cabal-|dotnet-|ghc-|libmono|mongodb-|mysql-|php)') \
firefox google-chrome-stable microsoft-edge-stable mono-devel mono-runtime-common monodoc-manual ruby
sudo apt autoremove -yq
sudo apt clean
sudo rm -fr /opt/ghc /opt/hostedtoolcache /usr/lib/node_modules /usr/local/share/boost /usr/share/dotnet /usr/share/swift
fi
- name: Build packages
env:
DOCKER_BUILD: ${{ steps.build-info.outputs.docker-build }}
run: |
declare -a packages
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
if [ -f ./built_${repo}_packages.txt ]; then
packages="$packages $(cat ./built_${repo}_packages.txt | tr '\n' ' ')"
fi
done
if [ ! -z "$packages" ]; then
if grep -qP "(^|\\s)${packages// /($|\\s)|(^|\\s)}($|\\s)" ./scripts/big-pkgs.list; then
NDK=$ANDROID_NDK_LATEST_HOME ANDROID_HOME=$ANDROID_SDK_ROOT ./build-package.sh --format pacman -I -a ${{ matrix.target_arch }} $packages
else
./scripts/run-docker.sh ./build-package.sh --format pacman -I -a ${{ matrix.target_arch }} $packages
fi
if [ "$DOCKER_BUILD" == 'false' ]; then
NDK=$ANDROID_NDK ANDROID_HOME=$ANDROID_SDK_ROOT ./build-package.sh --format pacman -I -a ${{ matrix.target_arch }} $packages
elif [ -n "$packages" ]; then
./scripts/run-docker.sh ./build-package.sh --format pacman -I -a ${{ matrix.target_arch }} $packages
fi
- name: Generate build artifacts