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: with:
fetch-depth: 1000 fetch-depth: 1000
- name: Gather build summary - name: Gather build summary
id: build-info
env:
MANUAL_INPUT_PACKAGES: ${{ github.event.inputs.packages }}
run: | run: |
if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then if [ "${{ github.event_name }}" != "workflow_dispatch" ]; then
BASE_COMMIT=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH") 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' # 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 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 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." echo "[!] Force exiting as tag '%ci:no-build' was applied to HEAD commit message."
exit 0 exit 0
fi 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 for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json) repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
# Parse changed files and identify new packages and deleted packages. # Parse changed files and identify new packages and deleted packages.
@@ -117,7 +112,10 @@ jobs:
done<<<${CHANGED_FILES} done<<<${CHANGED_FILES}
done done
else 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) repo_paths=$(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json)
found=false found=false
for repo_path in $repo_paths; do for repo_path in $repo_paths; do
@@ -153,6 +151,34 @@ jobs:
fi fi
done 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 - name: Lint packages
run: | run: |
declare -a package_recipes declare -a package_recipes
@@ -167,46 +193,44 @@ jobs:
./scripts/lint-packages.sh $package_recipes ./scripts/lint-packages.sh $package_recipes
fi 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: | run: |
declare -a packages declare -a packages
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json) repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
if [ -f ./built_${repo}_packages.txt ]; then if [ -f ./built_${repo}_packages.txt ]; then
packages="$packages $(cat ./built_${repo}_packages.txt | tr '\n' ' ')" packages="$packages $(cat ./built_${repo}_packages.txt | tr '\n' ' ')"
fi fi
done done
if [ ! -z "$packages" ]; then if [ "$DOCKER_BUILD" == 'false' ]; then
if grep -qP "(^|\\s)${packages// /($|\\s)|(^|\\s)}($|\\s)" ./scripts/big-pkgs.list; then ./scripts/setup-ubuntu.sh
./scripts/setup-ubuntu.sh sudo apt install ninja-build
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)') \
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
firefox google-chrome-stable microsoft-edge-stable mono-devel mono-runtime-common monodoc-manual ruby sudo apt autoremove -yq
sudo apt autoremove -yq sudo apt clean
sudo apt clean sudo rm -fr /opt/ghc /opt/hostedtoolcache /usr/lib/node_modules /usr/local/share/boost /usr/share/dotnet /usr/share/swift
sudo rm -fr /opt/hostedtoolcache /usr/lib/node_modules /usr/share/dotnet /usr/share/swift
fi
fi fi
- name: Build packages - name: Build packages
env:
DOCKER_BUILD: ${{ steps.build-info.outputs.docker-build }}
run: | run: |
declare -a packages declare -a packages
for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do for repo_path in $(jq --raw-output 'del(.pkg_format) | keys | .[]' repo.json); do
repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json) repo=$(jq --raw-output '.["'${repo_path}'"].name' repo.json)
if [ -f ./built_${repo}_packages.txt ]; then if [ -f ./built_${repo}_packages.txt ]; then
packages="$packages $(cat ./built_${repo}_packages.txt | tr '\n' ' ')" packages="$packages $(cat ./built_${repo}_packages.txt | tr '\n' ' ')"
fi fi
done done
if [ ! -z "$packages" ]; then if [ "$DOCKER_BUILD" == 'false' ]; then
if grep -qP "(^|\\s)${packages// /($|\\s)|(^|\\s)}($|\\s)" ./scripts/big-pkgs.list; then NDK=$ANDROID_NDK ANDROID_HOME=$ANDROID_SDK_ROOT ./build-package.sh --format pacman -I -a ${{ matrix.target_arch }} $packages
NDK=$ANDROID_NDK_LATEST_HOME ANDROID_HOME=$ANDROID_SDK_ROOT ./build-package.sh --format pacman -I -a ${{ matrix.target_arch }} $packages elif [ -n "$packages" ]; then
else ./scripts/run-docker.sh ./build-package.sh --format pacman -I -a ${{ matrix.target_arch }} $packages
./scripts/run-docker.sh ./build-package.sh --format pacman -I -a ${{ matrix.target_arch }} $packages
fi
fi fi
- name: Generate build artifacts - name: Generate build artifacts