Browse Source

CI: setup Github Actions

build-on-device
Leonid Plyushch 5 years ago
parent
commit
e1b86a41f2
  1. 29
      .github/workflows/docker_image.yml
  2. 92
      .github/workflows/packages.yml
  3. 48
      .github/workflows/repology_metadata.yml
  4. 56
      scripts/repology/excluded_packages.txt
  5. 96
      scripts/repology/generate-repology-metadata.sh

29
.github/workflows/docker_image.yml

@ -0,0 +1,29 @@
name: Docker image
on:
push:
branches:
- master
paths:
- 'scripts/Dockerfile'
- 'scripts/properties.sh'
- 'scripts/setup-android-sdk.sh'
- 'scripts/setup-ubuntu.sh'
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Build
run: |
cd ./scripts
docker build --tag termux/package-builder:latest .
- name: Push to hub.docker.com
env:
DOCKER_LOGIN: ${{ secrets.DOCKER_HUB_LOGIN }}
DOCKER_PASS: ${{ secrets.DOCKER_HUB_PASSWORD }}
run: |
docker login --username "${DOCKER_LOGIN}" --password "${DOCKER_PASS}"
docker push termux/package-builder:latest

92
.github/workflows/packages.yml

@ -0,0 +1,92 @@
name: Packages
on:
push:
branches:
- master
paths:
- 'packages/**'
pull_request:
paths:
- 'packages/**'
jobs:
build:
runs-on: ubuntu-latest
env:
ANDROID_HOME: "/opt/termux/android-sdk"
NDK: "/opt/termux/android-ndk"
strategy:
matrix:
target_arch: [aarch64, arm, i686, x86_64]
steps:
- name: Clone repository
uses: actions/checkout@v2
with:
fetch-depth: 1000
- name: Setup build environment
run: |
sudo mkdir -p /opt/termux
sudo chown $(id -u) /opt/termux
mkdir -p ./debs
./scripts/setup-ubuntu.sh
./scripts/setup-android-sdk.sh >/dev/null
- name: Build
run: |
BASE_COMMIT=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH")
OLD_COMMIT=$(jq --raw-output .commits[0].id "$GITHUB_EVENT_PATH")
HEAD_COMMIT=$(jq --raw-output .commits[-1].id "$GITHUB_EVENT_PATH")
if [ "$BASE_COMMIT" = "null" ]; then
if [ "$OLD_COMMIT" = "$HEAD_COMMIT" ]; then
echo "Processing commit: ${HEAD_COMMIT}"
CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r "${HEAD_COMMIT}")
else
echo "Processing commit range: ${OLD_COMMIT}..${HEAD_COMMIT}"
CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r "${OLD_COMMIT}" "${HEAD_COMMIT}")
fi
else
echo "Processing pull request #$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH"): ${BASE_COMMIT}..HEAD"
CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r "${BASE_COMMIT}" "HEAD")
fi
PACKAGE_NAMES=$(sed -nE 's@^packages/([^/]*)/([^/]*)(/.*)?$@\1@p' <<< "$CHANGED_FILES" | sort | uniq)
for pkg in $PACKAGE_NAMES; do
if [ ! -d "./packages/${pkg}" ]; then
PACKAGE_NAMES=$(sed -E "s/(^|\s\s*)${pkg}(\$|\s\s*)/ /g" <<< "$PACKAGE_NAMES")
echo "$pkg" >> ./debs/deleted_packages.txt
fi
done
PACKAGE_NAMES=$(sed 's/[[:blank:]]*$//' <<< "$PACKAGE_NAMES")
./build-package.sh -a ${{ matrix.target_arch }} -I ${PACKAGE_NAMES}
echo "${PACKAGE_NAMES}" > ./debs/built_packages.txt
- name: Store *.deb files
uses: actions/upload-artifact@v1
with:
name: termux-packages
path: ./debs
upload:
if: github.event_name != 'pull_request'
needs: build
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Get *.deb files
uses: actions/download-artifact@v1
with:
name: termux-packages
path: ./debs
- name: Upload to bintray.com
env:
BINTRAY_USERNAME: ${{ secrets.BINTRAY_USERNAME }}
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}
BINTRAY_GPG_SUBJECT: ${{ secrets.BINTRAY_GPG_SUBJECT }}
BINTRAY_GPG_PASSPHRASE: ${{ secrets.BINTRAY_GPG_PASSWORD }}
run: |
TO_DELETE=$(test -f ./debs/deleted_packages.txt && cat ./debs/deleted_packages.txt)
if [ -n "$TO_DELETE" ]; then
./scripts/package_uploader.sh -d $TO_DELETE
fi
TO_UPLOAD=$(test -f ./debs/built_packages.txt && cat ./debs/built_packages.txt)
if [ -n "$TO_UPLOAD" ]; then
./scripts/package_uploader.sh -p ./debs $TO_UPLOAD
fi

48
.github/workflows/repology_metadata.yml

@ -0,0 +1,48 @@
name: Repology metadata
on:
schedule:
- cron: '* */3 * * *'
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Clone supplementary package repositories
run: |
mkdir -p /tmp/repos
git clone --depth=1 https://github.com/termux/game-packages /tmp/repos/games
git clone --depth=1 https://github.com/termux/science-packages /tmp/repos/science
git clone --depth=1 https://github.com/termux/termux-root-packages /tmp/repos/root
git clone --depth=1 https://github.com/termux/unstable-packages /tmp/repos/unstable
git clone --depth=1 https://github.com/termux/x11-packages /tmp/repos/x11
- name: Process all Termux packages
run: |
mkdir -p generated
./scripts/repology/generate-repology-metadata.sh ./packages/* /tmp/repos/*/packages/* > ./generated/packages.json
- name: Upload metadata to bintray.com
env:
BINTRAY_USERNAME: ${{ secrets.BINTRAY_USERNAME }}
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}
run: |
response=$(curl --silent --user "${BINTRAY_USERNAME}:${BINTRAY_API_KEY}" --request DELETE --write-out "|%{http_code}" \
"https://api.bintray.com/content/termux/metadata/repology/packages.json")
if [[ $(echo "$response" | cut -d'|' -f2) != "200" ]] && [[ $(echo "$response" | cut -d'|' -f2) != "404" ]]; then
echo "Old medatata deletion failed !"
exit 1
fi
response=$(curl --silent --user "${BINTRAY_USERNAME}:${BINTRAY_API_KEY}" --request PUT \
--header "X-Bintray-Package: repology" --header "X-Bintray-Version: current" \
--header "X-Bintray-Publish: 1" --upload-file ./generated/packages.json --write-out "|%{http_code}" \
"https://api.bintray.com/content/termux/metadata/repology/packages.json")
if [[ $(echo "$response" | cut -d'|' -f2) != "201" ]] && [[ $(echo "$response" | cut -d'|' -f2) != "409" ]]; then
echo "New metadata uploading failed !"
exit 1
fi
- name: Store packages.json as artifact
uses: actions/upload-artifact@v1
with:
name: repology-metadata
path: ./generated/packages.json

56
scripts/repology/excluded_packages.txt

@ -0,0 +1,56 @@
##
## These packages are excluded from version checks.
##
# Can't be upgraded.
apt
# No official releases since 2.0b6.
beanshell
# Own implementation.
build-essential
# Ignore versions proposed by Repology.
# CA certificates are updated only if changed on upstream.
ca-certificates
# We use custom source bundle for this package.
cvs
# Different version scheme causes package to be marked 'out-of-date'.
dasm
# We use version 4.x, 5.x and higher should go to separate package.
docbook-xml
# Versions higher than 4.12 no longer working.
ecj
# v1.4.4 is the last update. Higher versions require Qt which is not suitable for termux-packages.
gpsbabel
# Own implementation.
libcrypt
# We use implementation from https://sourceforge.net/projects/libuuid/.
libuuid
# Can't be upgraded (NDK compatibility issues).
mesa
# Qt package is updated "as needed".
qt5-base
# We use https://github.com/RadhiFadlillah/shiori but Repology
# tracks https://aki-null.net/shiori/.
shiori
# Stick to v0.9.27 currently.
tcc
# v3.1 causes issues with ledger.
utf8cpp
# Can't be upgraded (3.x requires some Qt stuff that is unavailable in x11-packages).
wireshark-gtk

96
scripts/repology/generate-repology-metadata.sh

@ -0,0 +1,96 @@
#!/usr/bin/env bash
#
# Script for generating metadata for Repology in json format.
#
# Copyright 2018 Fredrik Fornwall <fredrik@fornwall.net> @fornwall
# Copyright 2019 Leonid Plyushch <leonid.plyushch@gmail.com> @xeffyr
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e
BASEDIR=$(dirname "$(realpath "$0")")
export TERMUX_ARCH=aarch64
check_package() { # path
# Avoid ending on errors such as $(which prog)
# where prog is not installed.
set +e
local path=$1
local pkg=$(basename $path)
TERMUX_PKG_MAINTAINER="Fredrik Fornwall @fornwall"
TERMUX_PKG_API_LEVEL=24
. $path/build.sh
echo " {"
echo " \"name\": \"$pkg\","
echo " \"version\": \"$TERMUX_PKG_VERSION\","
DESC=$(echo "$TERMUX_PKG_DESCRIPTION" | head -n 1)
echo " \"description\": \"$DESC\","
echo " \"homepage\": \"$TERMUX_PKG_HOMEPAGE\","
echo -n " \"depends\": ["
FIRST_DEP=yes
for p in ${TERMUX_PKG_DEPENDS//,/ }; do
if [ $FIRST_DEP = yes ]; then
FIRST_DEP=no
else
echo -n ", "
fi
echo -n "\"$p\""
done
echo "],"
if [ "$TERMUX_PKG_SRCURL" != "" ]; then
echo " \"srcurl\": \"$TERMUX_PKG_SRCURL\","
fi
echo " \"maintainer\": \"$TERMUX_PKG_MAINTAINER\""
echo -n " }"
}
check_excluded() {
if grep -q "^$1\$" "$BASEDIR/excluded_packages.txt"; then
return 0
else
return 1
fi
}
if [ $# -eq 0 ]; then
echo "Usage: generate-repology-metadata.sh [./path/to/pkg/dir] ..."
echo "Generate package metadata for Repology."
exit 1
fi
export FIRST=yes
echo '['
for path in "$@"; do
if check_excluded $(basename "$path"); then
continue
fi
if [ $FIRST = yes ]; then
FIRST=no
else
echo -n ","
echo ""
fi
# Run each package in separate process since we include their environment variables:
( check_package $path)
done
echo ""
echo ']'
Loading…
Cancel
Save