fdroid: add script that automates submissions
This script fetches a specified APK and analyzes it for values like version code or commit and then based on that creates a branchy and a commit in `fdroiddata` repository that can be used to create a release PR. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
389ce6695a
commit
5c52854d11
7
Makefile
7
Makefile
|
@ -171,6 +171,13 @@ fdroid-fix-tmp: ##@prepare Fix TMPDIR permissions so Vagrant user is the owner
|
||||||
|
|
||||||
fdroid-build-env: fdroid-max-watches fdroid-nix-dir fdroid-fix-tmp ##@prepare Setup build environment for F-Droud build
|
fdroid-build-env: fdroid-max-watches fdroid-nix-dir fdroid-fix-tmp ##@prepare Setup build environment for F-Droud build
|
||||||
|
|
||||||
|
fdroid-pr: export TARGET := android
|
||||||
|
fdroid-pr: ##@prepare Create F-Droid release PR
|
||||||
|
ifndef APK
|
||||||
|
$(error APK env var not defined)
|
||||||
|
endif
|
||||||
|
scripts/fdroid-pr.sh "$(APK)"
|
||||||
|
|
||||||
xcode-clean: SHELL := /bin/sh
|
xcode-clean: SHELL := /bin/sh
|
||||||
xcode-clean: XCODE_HOME := $(HOME)/Library/Developer/Xcode
|
xcode-clean: XCODE_HOME := $(HOME)/Library/Developer/Xcode
|
||||||
xcode-clean: ##@prepare Clean XCode derived data and archives
|
xcode-clean: ##@prepare Clean XCode derived data and archives
|
||||||
|
|
|
@ -14,6 +14,38 @@ First release of Status app was merged in [fdroid/fdroiddata#7179](https://gitla
|
||||||
|
|
||||||
# Adding New Versions
|
# Adding New Versions
|
||||||
|
|
||||||
|
There are two ways - automated and manual - described below.
|
||||||
|
|
||||||
|
## Automated
|
||||||
|
|
||||||
|
The script will analyze a provided APK, update the metadata file based on that information, and commit the change to [`fdroiddata`](https://gitlab.com/fdroid/fdroiddata) repo. The creation of merge request is manual.
|
||||||
|
|
||||||
|
#### Requirements:
|
||||||
|
|
||||||
|
- GitLab account
|
||||||
|
- Forked copy of the [`fdroiddata`](https://gitlab.com/fdroid/fdroiddata) repo
|
||||||
|
- Link to the release published
|
||||||
|
|
||||||
|
#### Steps
|
||||||
|
|
||||||
|
1. Use the F-Droid PR update script via `make`:
|
||||||
|
```sh
|
||||||
|
make fdroid-pr APK=StatusIm-Mobile-v1.16.0-ef34af.apk
|
||||||
|
```
|
||||||
|
The script also accepts a URL.
|
||||||
|
2. Add a fork repo:
|
||||||
|
```sh
|
||||||
|
git remote add john https://gitlab.com/john/fdroiddata.git
|
||||||
|
```
|
||||||
|
3. Push:
|
||||||
|
```sh
|
||||||
|
git push john status-im/v1.16.0
|
||||||
|
```
|
||||||
|
4. [Create a PR via the GitLab interface.](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||||
|
|
||||||
|
|
||||||
|
## Manual
|
||||||
|
|
||||||
You can find our configuration file at [`metadata/im.status.ethereum.yml`](https://gitlab.com/fdroid/fdroiddata/-/blob/master/metadata/im.status.ethereum.yml)
|
You can find our configuration file at [`metadata/im.status.ethereum.yml`](https://gitlab.com/fdroid/fdroiddata/-/blob/master/metadata/im.status.ethereum.yml)
|
||||||
|
|
||||||
The file defines all the necessary metadata like `SourceCode`, `Website`, or `License`, but the most important key is `Builds`, which looks like this:
|
The file defines all the necessary metadata like `SourceCode`, `Website`, or `License`, but the most important key is `Builds`, which looks like this:
|
||||||
|
@ -42,6 +74,7 @@ It contains a list of objects defining each release of the application. In order
|
||||||
The `versionCode` should be the same as the one in build that was uploaded to Play Store.
|
The `versionCode` should be the same as the one in build that was uploaded to Play Store.
|
||||||
It can be found in the build logs or by using:
|
It can be found in the build logs or by using:
|
||||||
```
|
```
|
||||||
|
> make shell TARGET=android
|
||||||
> apkanalyzer manifest version-code StatusIm-Mobile-v1.12.0.apk
|
> apkanalyzer manifest version-code StatusIm-Mobile-v1.12.0.apk
|
||||||
2021022512
|
2021022512
|
||||||
```
|
```
|
||||||
|
@ -99,6 +132,8 @@ The original research was done in [#8512](https://github.com/status-im/status-re
|
||||||
|
|
||||||
Normally F-Droid server wants to run Gradle itself, but we do not specify the `gradle` key in order to run `make release-fdroid` ourselves in `build` step. We also add `android/build.gradle` to `scanignore` to avoid F-Droid trying to use Gradle directly.
|
Normally F-Droid server wants to run Gradle itself, but we do not specify the `gradle` key in order to run `make release-fdroid` ourselves in `build` step. We also add `android/build.gradle` to `scanignore` to avoid F-Droid trying to use Gradle directly.
|
||||||
|
|
||||||
|
The Android metadata like description or screenshots is [loaded from our repository](https://f-droid.org/en/docs/All_About_Descriptions_Graphics_and_Screenshots/#fastlane-structure) based on the Fastlane [`supply`](https://docs.fastlane.tools/actions/supply/) tool folder structure for updating Google Play store metadata.
|
||||||
|
|
||||||
Once the PR is merged it may take a few days for the F-Droid server farm to build and deploy the new version to their site and app. You can look up the current state of builds [here](https://f-droid.org/wiki/index.php?title=Special:RecentChanges&days=7&from=&hidebots=0&hideanons=1&hideliu=1&limit=500) and look for your App ID and a `deploy` change after it.
|
Once the PR is merged it may take a few days for the F-Droid server farm to build and deploy the new version to their site and app. You can look up the current state of builds [here](https://f-droid.org/wiki/index.php?title=Special:RecentChanges&days=7&from=&hidebots=0&hideanons=1&hideliu=1&limit=500) and look for your App ID and a `deploy` change after it.
|
||||||
|
|
||||||
# F-Droid Build
|
# F-Droid Build
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
export YLW='\033[1;33m'
|
export YLW='\033[1;33m'
|
||||||
export RED='\033[0;31m'
|
export RED='\033[0;31m'
|
||||||
export GRN='\033[0;32m'
|
export GRN='\033[0;32m'
|
||||||
|
export BLU='\033[0;34m'
|
||||||
export BLD='\033[1m'
|
export BLD='\033[1m'
|
||||||
export RST='\033[0m'
|
export RST='\033[0m'
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
||||||
|
FDROIDATA_REPO_URL="https://gitlab.com/fdroid/fdroiddata.git"
|
||||||
|
WORKING_DIR="${HOME}/fdroid-release"
|
||||||
|
|
||||||
|
source "${GIT_ROOT}/scripts/colors.sh"
|
||||||
|
|
||||||
|
function log_info() { echo -e " ${GRN}>>>${RST} $@"; }
|
||||||
|
function log_data() { echo -e " ${BLU}===${RST} $@"; }
|
||||||
|
function log_notice() { echo -e " ${YLW}<<<${RST} $@"; }
|
||||||
|
function log_warning() { echo -e " ${RED}!!!${RST} $@"; }
|
||||||
|
|
||||||
|
if [[ $# -ne 1 ]]; then
|
||||||
|
echo "No release URL provided!" >&2
|
||||||
|
echo "Usage: fdroid-pr.sh https://.../release.apk" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# URL of APK to identify release version code
|
||||||
|
RELEASE_APK="${1}"
|
||||||
|
|
||||||
|
log_info "Creating working dir..."
|
||||||
|
mkdir -p "${WORKING_DIR}"
|
||||||
|
|
||||||
|
APK_FILE="${WORKING_DIR}/status.apk"
|
||||||
|
if [[ -f "${RELEASE_APK}" ]]; then
|
||||||
|
log_info "Using: ${RELEASE_APK}"
|
||||||
|
APK_FILE="${RELEASE_APK}"
|
||||||
|
else
|
||||||
|
log_info "Fetching release..."
|
||||||
|
curl -s "${RELEASE_APK}" -o "${APK_FILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_info "Parsing APK..."
|
||||||
|
|
||||||
|
VERSION_CODE=$(apkanalyzer manifest version-code "${APK_FILE}")
|
||||||
|
if [[ -n "${VERSION_CODE}" ]]; then
|
||||||
|
log_data "Version Code: ${VERSION_CODE}"
|
||||||
|
else
|
||||||
|
log_warning "Failed to find version code." >&2; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERSION_NAME=$(apkanalyzer manifest print "${APK_FILE}" | awk -F'"' '/android:versionName/{print $2}')
|
||||||
|
if [[ -n "${VERSION_NAME}" ]]; then
|
||||||
|
log_data "Version Code: ${VERSION_NAME}"
|
||||||
|
else
|
||||||
|
log_warning "Failed to find version name." >&2; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
COMMIT_HASH=$(apkanalyzer manifest print "${APK_FILE}" | awk -F'"' '/commitHash/{getline; print $2}')
|
||||||
|
if [[ -n "${COMMIT_HASH}" ]]; then
|
||||||
|
log_data "Commit Hash: ${COMMIT_HASH}"
|
||||||
|
else
|
||||||
|
log_warning "Failed to find commit hash." >&2; exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
CLONE_DIR="${WORKING_DIR}/fdroidata"
|
||||||
|
METADATA_FILE="${CLONE_DIR}/metadata/im.status.ethereum.yml"
|
||||||
|
|
||||||
|
PREVIOUS_BRANCH=""
|
||||||
|
if [[ -d "${CLONE_DIR}" ]]; then
|
||||||
|
log_info "Fetching: ${FDROIDATA_REPO_URL}"
|
||||||
|
cd "${CLONE_DIR}"
|
||||||
|
PREVIOUS_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
git checkout master
|
||||||
|
git pull --force
|
||||||
|
else
|
||||||
|
log_info "Cloning: ${FDROIDATA_REPO_URL}"
|
||||||
|
git clone -q --depth=1 "${FDROIDATA_REPO_URL}" "${CLONE_DIR}"
|
||||||
|
cd "${CLONE_DIR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
BRANCH_NAME="status-im/v${VERSION_NAME}"
|
||||||
|
log_info "Checkout out branch: ${BRANCH_NAME}"
|
||||||
|
if [[ "${PREVIOUS_BRANCH}" == "${BRANCH_NAME}" ]]; then
|
||||||
|
log_warning "Removing previous branch: ${PREVIOUS_BRANCH}"
|
||||||
|
git branch -D "${BRANCH_NAME}"
|
||||||
|
fi
|
||||||
|
git switch -C "${BRANCH_NAME}"
|
||||||
|
|
||||||
|
log_info "Updating metadata file..."
|
||||||
|
|
||||||
|
# find line number of last "versionName" line
|
||||||
|
START_LINE=$(awk '/ versionCode:/{n=NR} END{print n}' "${METADATA_FILE}")
|
||||||
|
# find line number of last "build" line
|
||||||
|
END_LINE=$(awk '/ build:/{n=NR} END{print n}' "${METADATA_FILE}")
|
||||||
|
# Get the latest entry, excluding version info
|
||||||
|
BUILD_PARAMS=$(awk "NR >= $((START_LINE+2)) && NR <= ${END_LINE}" "${METADATA_FILE}")
|
||||||
|
|
||||||
|
# Build new entry
|
||||||
|
NEW_ENTRY="
|
||||||
|
- versionName: ${VERSION_NAME}
|
||||||
|
versionCode: ${VERSION_CODE}
|
||||||
|
commit: ${COMMIT_HASH}
|
||||||
|
${BUILD_PARAMS}"
|
||||||
|
|
||||||
|
# Insert new release build entry
|
||||||
|
sed -i "$((END_LINE+1))i\\${NEW_ENTRY//$'\n'/\\n}" "${METADATA_FILE}"
|
||||||
|
# Update current version values
|
||||||
|
sed -i "s/CurrentVersion: .*/CurrentVersion: ${VERSION_NAME}/" "${METADATA_FILE}"
|
||||||
|
sed -i "s/CurrentVersionCode: .*/CurrentVersionCode: ${VERSION_CODE}/" "${METADATA_FILE}"
|
||||||
|
|
||||||
|
log_info "Committing changes..."
|
||||||
|
# Add, commit and push
|
||||||
|
COMMIT_MESSAGE="Update Status to ${VERSION_NAME} (${VERSION_CODE})"
|
||||||
|
git add ${METADATA_FILE}
|
||||||
|
git commit -m "${COMMIT_MESSAGE}"
|
||||||
|
|
||||||
|
log_info "SUCCESS"
|
||||||
|
log_notice "Now add your fork of fdroidata as a remote to the repository and push."
|
||||||
|
log_notice "Then create a Merge Request from the branch in your fork."
|
||||||
|
log_notice "Repo path: ${BLD}${CLONE_DIR}${RST}"
|
Loading…
Reference in New Issue