Leonid Plyushch
5 years ago
2 changed files with 0 additions and 321 deletions
@ -1,156 +0,0 @@ |
|||||
container: |
|
||||
image: termux/package-builder:latest |
|
||||
|
|
||||
## |
|
||||
## When doing release builds (branch 'master'), update Docker image if |
|
||||
## required. |
|
||||
## |
|
||||
docker_builder: |
|
||||
name: Update docker image |
|
||||
|
|
||||
only_if: $CIRRUS_BRANCH == 'master' |
|
||||
|
|
||||
env: |
|
||||
DOCKER_USERNAME: xeffyr |
|
||||
DOCKER_PASSWORD: ENCRYPTED[abe4dc4418b40a4c5a0c1671e4018fd9cc3bcb811a71f87bdb35967ba721501f958d47d48a3d31ab9cac466b48f238a0] |
|
||||
|
|
||||
script: | |
|
||||
bash ./scripts/build/ci/cirrus-ci_dispatcher.sh --update-docker |
|
||||
|
|
||||
## |
|
||||
## Perform basic check for errors in build.sh package scripts. |
|
||||
## If error found, exit with error code to stop build. |
|
||||
## |
|
||||
task: |
|
||||
container: |
|
||||
cpu: 1 |
|
||||
memory: 4 |
|
||||
|
|
||||
name: Lint packages |
|
||||
|
|
||||
timeout_in: 5m |
|
||||
|
|
||||
depends_on: |
|
||||
- Update docker image |
|
||||
|
|
||||
script: | |
|
||||
bash scripts/lint-packages.sh |
|
||||
|
|
||||
## |
|
||||
## Determine changes in the last push, find modified packages and |
|
||||
## build them for aarch64/arm/i686/x86_64 architectures. |
|
||||
## |
|
||||
## Built packages are accessible from Cirrus CI web interface. |
|
||||
## |
|
||||
task: |
|
||||
container: |
|
||||
# Max configuration required by few large packages such as `rust`. |
|
||||
cpu: 8 |
|
||||
memory: 24 |
|
||||
|
|
||||
name: Build packages |
|
||||
|
|
||||
# 2 hours is a maximal timeout available for free use. |
|
||||
timeout_in: 120m |
|
||||
|
|
||||
depends_on: |
|
||||
- Lint packages |
|
||||
|
|
||||
environment: |
|
||||
TERMUX_MAKE_PROCESSES: 8 |
|
||||
matrix: |
|
||||
- TERMUX_ARCH: aarch64 |
|
||||
- TERMUX_ARCH: arm |
|
||||
- TERMUX_ARCH: i686 |
|
||||
- TERMUX_ARCH: x86_64 |
|
||||
|
|
||||
# Do not use built-in git client provided by Cirrus as it may |
|
||||
# cause problems when determining changed files. |
|
||||
clone_script: | |
|
||||
if [[ -z "$CIRRUS_PR" ]]; then |
|
||||
git clone --recursive --branch="$CIRRUS_BRANCH" "https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git" "$CIRRUS_WORKING_DIR" |
|
||||
git reset --hard "$CIRRUS_CHANGE_IN_REPO" |
|
||||
else |
|
||||
git clone --recursive "https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git" "$CIRRUS_WORKING_DIR" |
|
||||
git fetch origin "pull/$CIRRUS_PR/head:pull/$CIRRUS_PR" |
|
||||
git reset --hard "$CIRRUS_CHANGE_IN_REPO" |
|
||||
fi |
|
||||
|
|
||||
build_script: | |
|
||||
export TERMUX_DEBDIR="/tmp/debs-${TERMUX_ARCH}" |
|
||||
ln -s "$TERMUX_DEBDIR" debs |
|
||||
bash ./scripts/build/ci/cirrus-ci_dispatcher.sh |
|
||||
|
|
||||
aarch64_debs_cache: |
|
||||
folder: "/tmp/debs-aarch64" |
|
||||
fingerprint_script: echo "${CIRRUS_CHANGE_IN_REPO}-aarch64" |
|
||||
|
|
||||
arm_debs_cache: |
|
||||
folder: "/tmp/debs-arm" |
|
||||
fingerprint_script: echo "${CIRRUS_CHANGE_IN_REPO}-arm" |
|
||||
|
|
||||
i686_debs_cache: |
|
||||
folder: "/tmp/debs-i686" |
|
||||
fingerprint_script: echo "${CIRRUS_CHANGE_IN_REPO}-i686" |
|
||||
|
|
||||
x86-64_debs_cache: |
|
||||
folder: "/tmp/debs-x86_64" |
|
||||
fingerprint_script: echo "${CIRRUS_CHANGE_IN_REPO}-x86_64" |
|
||||
|
|
||||
output_artifacts: |
|
||||
path: "./debs/*.deb" |
|
||||
|
|
||||
## |
|
||||
## When doing release build (branch 'master'), upload built packages |
|
||||
## to APT repository on Bintray. |
|
||||
## |
|
||||
task: |
|
||||
container: |
|
||||
cpu: 1 |
|
||||
memory: 4 |
|
||||
|
|
||||
name: Upload packages to Bintray |
|
||||
|
|
||||
only_if: $CIRRUS_BRANCH == 'master' |
|
||||
|
|
||||
timeout_in: 60m |
|
||||
|
|
||||
depends_on: |
|
||||
- Build packages |
|
||||
|
|
||||
environment: |
|
||||
BINTRAY_USERNAME: xeffyr |
|
||||
BINTRAY_API_KEY: ENCRYPTED[c056d345d7a15f90b818dd9382129c27ce4ce2b802831ec890786414fc214c4203714c353a8fef3a6b9b1b1d68e4685e] |
|
||||
BINTRAY_GPG_SUBJECT: termux |
|
||||
BINTRAY_GPG_PASSPHRASE: ENCRYPTED[854c09c78b3318a30d3c9094b1010dfebd4c71ad9173b64479eaafaa7e941b050afaa936ad635af3709382492828316f] |
|
||||
|
|
||||
# Do not use built-in git client provided by Cirrus as it may |
|
||||
# cause problems when determining changed files. |
|
||||
clone_script: | |
|
||||
if [[ -z "$CIRRUS_PR" ]]; then |
|
||||
git clone --recursive --branch="$CIRRUS_BRANCH" "https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git" "$CIRRUS_WORKING_DIR" |
|
||||
git reset --hard "$CIRRUS_CHANGE_IN_REPO" |
|
||||
else |
|
||||
git clone --recursive "https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git" "$CIRRUS_WORKING_DIR" |
|
||||
git fetch origin "pull/$CIRRUS_PR/head:pull/$CIRRUS_PR" |
|
||||
git reset --hard "$CIRRUS_CHANGE_IN_REPO" |
|
||||
fi |
|
||||
|
|
||||
aarch64_debs_cache: |
|
||||
folder: "./debs" |
|
||||
fingerprint_script: echo "${CIRRUS_CHANGE_IN_REPO}-aarch64" |
|
||||
|
|
||||
arm_debs_cache: |
|
||||
folder: "./debs" |
|
||||
fingerprint_script: echo "${CIRRUS_CHANGE_IN_REPO}-arm" |
|
||||
|
|
||||
i686_debs_cache: |
|
||||
folder: "./debs" |
|
||||
fingerprint_script: echo "${CIRRUS_CHANGE_IN_REPO}-i686" |
|
||||
|
|
||||
x86-64_debs_cache: |
|
||||
folder: "./debs" |
|
||||
fingerprint_script: echo "${CIRRUS_CHANGE_IN_REPO}-x86_64" |
|
||||
|
|
||||
script: | |
|
||||
bash ./scripts/build/ci/cirrus-ci_dispatcher.sh --upload |
|
@ -1,165 +0,0 @@ |
|||||
#!/bin/bash |
|
||||
## |
|
||||
## Determine modified packages and build/upload them. |
|
||||
## |
|
||||
|
|
||||
set -e |
|
||||
|
|
||||
## Some packages should be excluded from auto builds. |
|
||||
EXCLUDED_PACKAGES="texlive" |
|
||||
|
|
||||
############################################################################### |
|
||||
## |
|
||||
## Determining changes. |
|
||||
## |
|
||||
############################################################################### |
|
||||
|
|
||||
set +e |
|
||||
|
|
||||
REPO_DIR=$(realpath "$(dirname "$(realpath "$0")")/../../../") |
|
||||
cd "$REPO_DIR" || { |
|
||||
echo "[!] Failed to cd into '$REPO_DIR'." |
|
||||
exit 1 |
|
||||
} |
|
||||
|
|
||||
# Some environment variables are important for correct functionality |
|
||||
# of this script. |
|
||||
if [ -z "$CIRRUS_CHANGE_IN_REPO" ]; then |
|
||||
echo "[!] CIRRUS_CHANGE_IN_REPO is not set." |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
if [ -n "$CIRRUS_PR" ] && [ -z "$CIRRUS_BASE_SHA" ]; then |
|
||||
echo "[!] CIRRUS_BASE_SHA is not set." |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
# Process tag '%ci:no-build' that may be added as line to commit message. |
|
||||
# Will force CI to exit with status 'passed' without performing build. |
|
||||
if grep -qiP '^\s*%ci:no-build\s*$' <(git log --format="%B" -n 1 "$CIRRUS_CHANGE_IN_REPO"); then |
|
||||
echo "[!] Exiting with status 'passed' (tag '%ci:no-build' applied)." |
|
||||
exit 0 |
|
||||
fi |
|
||||
|
|
||||
# Process tag '%ci:reset-backlog' that may be added as line to commit message. |
|
||||
# Will force CI to build changes only for the current commit. |
|
||||
if grep -qiP '^\s*%ci:reset-backlog\s*$' <(git log --format="%B" -n 1 "$CIRRUS_CHANGE_IN_REPO"); then |
|
||||
echo "[!] Building only last pushed commit (tag '%ci:reset-backlog' applied)." |
|
||||
unset CIRRUS_LAST_GREEN_CHANGE |
|
||||
unset CIRRUS_BASE_SHA |
|
||||
fi |
|
||||
|
|
||||
if [ -z "$CIRRUS_PR" ]; then |
|
||||
# Changes determined from the last commit where CI finished with status |
|
||||
# 'passed' (green) and the top commit. |
|
||||
if [ -z "$CIRRUS_LAST_GREEN_CHANGE" ]; then |
|
||||
GIT_CHANGES="$CIRRUS_CHANGE_IN_REPO" |
|
||||
else |
|
||||
GIT_CHANGES="${CIRRUS_LAST_GREEN_CHANGE}..${CIRRUS_CHANGE_IN_REPO}" |
|
||||
fi |
|
||||
echo "[*] Changes: $GIT_CHANGES" |
|
||||
else |
|
||||
# Changes in pull request are determined from commits between the |
|
||||
# top commit of base branch and latest commit of PR's branch. |
|
||||
GIT_CHANGES="${CIRRUS_BASE_SHA}..${CIRRUS_CHANGE_IN_REPO}" |
|
||||
echo "[*] Pull request: https://github.com/termux/termux-packages/pull/${CIRRUS_PR}" |
|
||||
fi |
|
||||
|
|
||||
# Determine changes from commit range. |
|
||||
CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r "$GIT_CHANGES" 2>/dev/null) |
|
||||
|
|
||||
# Modified packages. |
|
||||
PACKAGE_NAMES=$(sed -nE 's@^packages/([^/]*)/build.sh@\1@p' <<< "$CHANGED_FILES") |
|
||||
|
|
||||
# Docker scripts. |
|
||||
DOCKER_SCRIPTS=$(grep -P '^scripts/(Dockerfile|properties.sh|setup-android-sdk.sh|setup-ubuntu.sh)$' <<< "$CHANGED_FILES") |
|
||||
[ -n "$DOCKER_SCRIPTS" ] && DOCKER_IMAGE_UPDATE_NEEDED=true || DOCKER_IMAGE_UPDATE_NEEDED=false |
|
||||
|
|
||||
unset CHANGED_FILES |
|
||||
|
|
||||
## Filter deleted packages. |
|
||||
for pkg in $PACKAGE_NAMES; do |
|
||||
if [ ! -d "${REPO_DIR}/packages/${pkg}" ]; then |
|
||||
PACKAGE_NAMES=$(sed -E "s/(^|\s\s*)${pkg}(\$|\s\s*)/ /g" <<< "$PACKAGE_NAMES") |
|
||||
fi |
|
||||
done |
|
||||
|
|
||||
## Filter excluded packages. |
|
||||
for pkg in $EXCLUDED_PACKAGES; do |
|
||||
PACKAGE_NAMES=$(sed -E "s/(^|\s\s*)${pkg}(\$|\s\s*)/ /g" <<< "$PACKAGE_NAMES") |
|
||||
done |
|
||||
unset pkg |
|
||||
|
|
||||
## Remove trailing spaces. |
|
||||
PACKAGE_NAMES=$(sed 's/[[:blank:]]*$//' <<< "$PACKAGE_NAMES") |
|
||||
|
|
||||
set -e |
|
||||
|
|
||||
############################################################################### |
|
||||
## |
|
||||
## Executing requested actions. Only one per script session. |
|
||||
## |
|
||||
############################################################################### |
|
||||
|
|
||||
case "$1" in |
|
||||
--update-docker) |
|
||||
if $DOCKER_IMAGE_UPDATE_NEEDED; then |
|
||||
if [ "$CIRRUS_BRANCH" != "master" ]; then |
|
||||
echo "[!] Refusing to update docker image on non-master branch." |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
if [ -z "$DOCKER_USERNAME" ]; then |
|
||||
echo "[!] Can't update docker image without Docker Hub user name." |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
if [ -z "$DOCKER_PASSWORD" ]; then |
|
||||
echo "[!] Can't update docker image without Docker Hub password." |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
cd "${REPO_DIR}/scripts" |
|
||||
|
|
||||
docker build --tag termux/package-builder:latest . |
|
||||
docker login --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD" |
|
||||
docker push termux/package-builder:latest |
|
||||
else |
|
||||
echo "[*] No need to update docker image." |
|
||||
exit 0 |
|
||||
fi |
|
||||
;; |
|
||||
--upload) |
|
||||
if [ -n "$PACKAGE_NAMES" ]; then |
|
||||
if [ "$CIRRUS_BRANCH" != "master" ]; then |
|
||||
echo "[!] Refusing to upload packages on non-master branch." |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
if [ -z "$BINTRAY_API_KEY" ]; then |
|
||||
echo "[!] Can't upload packages without Bintray API key." |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
if [ -z "$BINTRAY_GPG_PASSPHRASE" ]; then |
|
||||
echo "[!] Can't upload packages without GPG passphrase." |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
echo "[*] Uploading packages to Bintray:" |
|
||||
"${REPO_DIR}/scripts/package_uploader.sh" -p "${PWD}/debs" $PACKAGE_NAMES |
|
||||
else |
|
||||
echo "[*] No modified packages found." |
|
||||
exit 0 |
|
||||
fi |
|
||||
;; |
|
||||
*) |
|
||||
if [ -n "$PACKAGE_NAMES" ]; then |
|
||||
echo "[*] Building packages:" $PACKAGE_NAMES |
|
||||
./build-package.sh -a "$TERMUX_ARCH" -I $PACKAGE_NAMES |
|
||||
else |
|
||||
echo "[*] No modified packages found." |
|
||||
exit 0 |
|
||||
fi |
|
||||
;; |
|
||||
esac |
|
Loading…
Reference in new issue