gitlab-ci: push nightly builds to fdroid repo on gitlab
If a repo is set with the gitlab-ci Secret Variable DEBUG_KEYSTORE and there is a repo named the same as this repo with -nightly appended, then this will automatically generate an fdroid repo of each build produced by gitlab-ci runs on the master branch. closes fdroidserver#256
This commit is contained in:
parent
5e91bb7892
commit
f0438a67b1
@ -5,12 +5,17 @@ cache:
|
|||||||
- .gradle/wrapper
|
- .gradle/wrapper
|
||||||
- .gradle/caches
|
- .gradle/caches
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- test
|
||||||
|
- deploy
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- export GRADLE_USER_HOME=$PWD/.gradle
|
- export GRADLE_USER_HOME=$PWD/.gradle
|
||||||
- export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdkVersion\s*\([0-9][0-9]*\).*,\1,p' app/build.gradle`
|
- export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdkVersion\s*\([0-9][0-9]*\).*,\1,p' app/build.gradle`
|
||||||
- echo y | android --silent update sdk --no-ui --filter android-${ANDROID_COMPILE_SDK}
|
- echo y | android --silent update sdk --no-ui --filter android-${ANDROID_COMPILE_SDK}
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
stage: test
|
||||||
script:
|
script:
|
||||||
- export EXITVALUE=0
|
- export EXITVALUE=0
|
||||||
- ./tools/check-format-strings.py
|
- ./tools/check-format-strings.py
|
||||||
@ -33,6 +38,7 @@ test:
|
|||||||
- exit $EXITVALUE
|
- exit $EXITVALUE
|
||||||
|
|
||||||
connected10:
|
connected10:
|
||||||
|
stage: test
|
||||||
variables:
|
variables:
|
||||||
AVD_SDK: "10"
|
AVD_SDK: "10"
|
||||||
script:
|
script:
|
||||||
@ -54,6 +60,7 @@ connected10:
|
|||||||
done
|
done
|
||||||
|
|
||||||
connected24:
|
connected24:
|
||||||
|
stage: test
|
||||||
variables:
|
variables:
|
||||||
AVD_SDK: "24"
|
AVD_SDK: "24"
|
||||||
script:
|
script:
|
||||||
@ -77,6 +84,13 @@ connected24:
|
|||||||
done
|
done
|
||||||
- exit $EXITVALUE
|
- exit $EXITVALUE
|
||||||
|
|
||||||
|
deploy_nightly:
|
||||||
|
stage: deploy
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
script:
|
||||||
|
- "[ -z \"$DEBUG_KEYSTORE\" ] || ./config/nightly-repo/deploy"
|
||||||
|
|
||||||
after_script:
|
after_script:
|
||||||
# this file changes every time but should not be cached
|
# this file changes every time but should not be cached
|
||||||
- rm -f $GRADLE_USER_HOME/caches/modules-2/modules-2.lock
|
- rm -f $GRADLE_USER_HOME/caches/modules-2/modules-2.lock
|
||||||
|
18
config/nightly-repo/config.py
Normal file
18
config/nightly-repo/config.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
repo_icon = "fdroid-icon.png"
|
||||||
|
repo_description = """
|
||||||
|
This repo is nightly builds, it should only be used for testing!
|
||||||
|
"""
|
||||||
|
|
||||||
|
archive_older = 10
|
||||||
|
archive_icon = "fdroid-icon.png"
|
||||||
|
archive_description = """
|
||||||
|
The repository of older versions of applications from the main repository.
|
||||||
|
"""
|
||||||
|
|
||||||
|
make_current_version_link = False
|
||||||
|
accepted_formats = ('txt', 'yml')
|
||||||
|
repo_keyalias = "androiddebugkey"
|
||||||
|
keystorepass = "android"
|
||||||
|
keypass = "android"
|
||||||
|
keydname = "CN=Android Debug,O=Android,C=US"
|
86
config/nightly-repo/deploy
Executable file
86
config/nightly-repo/deploy
Executable file
@ -0,0 +1,86 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
echo "deb http://deb.debian.org/debian stretch-backports main" \
|
||||||
|
> /etc/apt/sources.list.d/stretch-backports.list
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y --no-install-recommends -t stretch-backports \
|
||||||
|
fdroidserver openssh-client rsync python3-qrcode
|
||||||
|
|
||||||
|
db=`sed -n 's,.*DB_VERSION *= *\([0-9][0-9]*\).*,\1,p' app/src/main/java/org/fdroid/fdroid/data/DBHelper.java`
|
||||||
|
count=`git rev-list --first-parent --count HEAD`
|
||||||
|
sed -i "s,versionCode *[0-9][0-9]*.*,versionCode `printf '%d%05d' $db $count`," app/build.gradle
|
||||||
|
|
||||||
|
repo_git_base=${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}-nightly
|
||||||
|
repo_base=https://gitlab.com/${repo_git_base}
|
||||||
|
repo_url=${repo_base}/raw/master/fdroid/repo
|
||||||
|
archive_url=${repo_base}/raw/master/fdroid/archive
|
||||||
|
mkdir -p $HOME/.android
|
||||||
|
keystore=$HOME/.android/debug.keystore
|
||||||
|
echo "repo_name = '$repo_git_base'" >> config/nightly-repo/config.py
|
||||||
|
echo "repo_url = '$repo_url'" >> config/nightly-repo/config.py
|
||||||
|
echo "archive_name = '$repo_git_base archive'" >> config/nightly-repo/config.py
|
||||||
|
echo "archive_url = '$archive_url'" >> config/nightly-repo/config.py
|
||||||
|
echo "servergitmirrors = 'git@gitlab.com:$repo_git_base'" >> config/nightly-repo/config.py
|
||||||
|
echo "keystore = '$keystore'" >> config/nightly-repo/config.py
|
||||||
|
chmod 0600 config/nightly-repo/config.py
|
||||||
|
|
||||||
|
sed -i -e '/<\/string-array>/d' -e '/<\/resources>/d' \
|
||||||
|
app/src/main/res/values/default_repos.xml
|
||||||
|
echo "<item>$repo_git_base</item>" >> app/src/main/res/values/default_repos.xml
|
||||||
|
echo "<item>$repo_url</item>" >> app/src/main/res/values/default_repos.xml
|
||||||
|
cat config/nightly-repo/repo.xml >> app/src/main/res/values/default_repos.xml
|
||||||
|
echo "</string-array></resources>" >> app/src/main/res/values/default_repos.xml
|
||||||
|
|
||||||
|
set +x # do not show contents of secret variables!
|
||||||
|
echo $DEBUG_KEYSTORE | base64 --decode --ignore-garbage > $keystore
|
||||||
|
set -x
|
||||||
|
|
||||||
|
./gradlew assembleDebug -PdisablePreDex
|
||||||
|
|
||||||
|
mkdir config/nightly-repo/repo/
|
||||||
|
mv app/build/outputs/apk/app-debug.apk config/nightly-repo/repo/
|
||||||
|
cd config/nightly-repo
|
||||||
|
|
||||||
|
pw=android
|
||||||
|
alias=androiddebugkey
|
||||||
|
keytool -v -importkeystore \
|
||||||
|
-srckeystore $keystore -srcalias $alias -srcstorepass $pw -srckeypass $pw \
|
||||||
|
-destkeystore keystore.p12 -destalias $alias -deststorepass $pw -destkeypass $pw -deststoretype PKCS12
|
||||||
|
|
||||||
|
ssh_private_key=$HOME/.ssh/id_rsa
|
||||||
|
mkdir -p $(dirname $ssh_private_key)
|
||||||
|
openssl pkcs12 -in keystore.p12 -out key.pem -passin pass:$pw -passout pass:$pw
|
||||||
|
openssl rsa -in key.pem -out ${ssh_private_key} -passin pass:$pw
|
||||||
|
chmod 600 ${ssh_private_key}
|
||||||
|
ssh-keygen -y -f ${ssh_private_key} > ${ssh_private_key}.pub
|
||||||
|
echo "SSH public deploy key:"
|
||||||
|
cat ${ssh_private_key}.pub
|
||||||
|
eval $(ssh-agent -s)
|
||||||
|
ssh-add ${ssh_private_key}
|
||||||
|
|
||||||
|
if git clone $repo_base git-mirror; then
|
||||||
|
cd git-mirror
|
||||||
|
git remote rm origin
|
||||||
|
qr $repo_url > qr.png
|
||||||
|
echo "# $repo_git_base" > README.md
|
||||||
|
echo "[]($repo_url)" >> README.md
|
||||||
|
printf "\n\nLast updated: " >> README.md
|
||||||
|
date >> README.md
|
||||||
|
git add README.md
|
||||||
|
git config user.email "$CI_PROJECT_NAMESPACE@$CI_PROJECT_NAME"
|
||||||
|
git config user.name "$CI_PROJECT_NAMESPACE $CI_PROJECT_NAME"
|
||||||
|
git commit README.md -m README
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
|
if [ -d git-mirror/fdroid/repo ]; then
|
||||||
|
rsync -axv git-mirror/fdroid/repo/ repo/
|
||||||
|
fi
|
||||||
|
|
||||||
|
fdroid update --rename-apks
|
||||||
|
|
||||||
|
ssh-add -l
|
||||||
|
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" >> ~/.ssh/config
|
||||||
|
fdroid server update --verbose
|
BIN
config/nightly-repo/fdroid-icon.png
Normal file
BIN
config/nightly-repo/fdroid-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
15
config/nightly-repo/metadata/org.fdroid.fdroid.yml
Normal file
15
config/nightly-repo/metadata/org.fdroid.fdroid.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
Categories: System
|
||||||
|
License: GPL-3.0+
|
||||||
|
WebSite: https://f-droid.org
|
||||||
|
SourceCode: https://gitlab.com/fdroid/fdroidclient
|
||||||
|
IssueTracker: https://gitlab.com/fdroid/fdroidclient/issues
|
||||||
|
Changelog: https://gitlab.com/fdroid/fdroidclient/raw/HEAD/CHANGELOG.md
|
||||||
|
Donate: https://f-droid.org/about
|
||||||
|
FlattrID: 343053
|
||||||
|
Bitcoin: 15u8aAPK4jJ5N8wpWJ5gutAyyeHtKX5i18
|
||||||
|
|
||||||
|
AutoName: F-Droid Nightly
|
||||||
|
Summary: Nightly test build of F-Droid
|
||||||
|
|
||||||
|
RepoType: srclib
|
||||||
|
Repo: fdroidclient
|
14
config/nightly-repo/repo.xml
Normal file
14
config/nightly-repo/repo.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<!-- description -->
|
||||||
|
<item>This repo is nightly builds of F-Droid, it should only be used for testing!</item>
|
||||||
|
<!-- version -->
|
||||||
|
<item>13</item>
|
||||||
|
<!-- enabled -->
|
||||||
|
<item>1</item>
|
||||||
|
<!-- priority -->
|
||||||
|
<item>5</item>
|
||||||
|
<!-- push requests -->
|
||||||
|
<item>ignore</item>
|
||||||
|
<!-- pubkey -->
|
||||||
|
<item>
|
||||||
|
308201e53082014ea0030201020204503d3768300d06092a864886f70d01010505003037310b30090603550406130255533110300e060355040a1307416e64726f6964311630140603550403130d416e64726f6964204465627567301e170d3132303832383231323630305a170d3432303832313231323630305a3037310b30090603550406130255533110300e060355040a1307416e64726f6964311630140603550403130d416e64726f696420446562756730819f300d06092a864886f70d010101050003818d0030818902818100b5ba553eacbc4de5b45af812d9695140dafbc0a8a9c13ac9a7e24b2665371ce5072e5dfef60f705d58fdb2d0e2190264e42d83a6fd80cfd54690e9e3c3735fa8dce684ee99ac879b1b11e1c8a9cbb9dc6b23064b025f9db7dc87d48ee4bc038affd80d854c0ed5d88d93d6e8127e62344727e23886b97f5d10e2265c9c9b5bd10203010001300d06092a864886f70d0101050500038181006dae218bdbff79801b1935448c663319843a7b2eb5f5c8837f010e58da25ba4d23bc6650b53c93f9c42b379299f4659b4cc3c505aa1a7c08c8a1a58fffe78d29df2cf69b27c34a0ab5f44cf7e323e34f8252d9f6e4d67171ce38bab64623910811dae6b12203385b32d962dbd51e8a6b0dcab3fa4d1f4020cee69a5f3c6ddf69
|
||||||
|
</item>
|
Loading…
x
Reference in New Issue
Block a user