diff --git a/.github/workflows/fdroid.yml b/.github/workflows/fdroid.yml index 93fbba2a..fe88c6d2 100644 --- a/.github/workflows/fdroid.yml +++ b/.github/workflows/fdroid.yml @@ -53,8 +53,8 @@ jobs: - name: Run update script run: cd fdroid-repo/fdroid && bash update.sh 2>&1 - - name: Remove repo secrets - run: rm -r fdroid-repo/fdroid/keystore.p12 fdroid-repo/fdroid/config.yml fdroid-repo/fdroid/tmp fdroid-repo/fdroid/srclibs fdroid-repo/fdroid/update.sh + - name: Remove unneded files and secrets + run: rm -r fdroid-repo/fdroid/keystore.p12 fdroid-repo/fdroid/config.yml fdroid-repo/fdroid/tmp fdroid-repo/fdroid/srclibs fdroid-repo/fdroid/update.sh fdroid-repo/fdroid/metadata - name: Fix permissions run: | diff --git a/fdroid-repo/fdroid/update.sh b/fdroid-repo/fdroid/update.sh index 661ca2d8..d62e082a 100644 --- a/fdroid-repo/fdroid/update.sh +++ b/fdroid-repo/fdroid/update.sh @@ -6,46 +6,39 @@ PACKAGE=com.arn.scrobble # Define the URL of the GitHub repository REPO_URL="https://api.github.com/repos/$USER/$REPO/releases" -# Check if jq package is installed, and install it if necessary -if ! command -v jq &> /dev/null; then - sudo apt-get install -y jq -fi - # Use curl to get the JSON response for all releases JSON=$(curl --silent "$REPO_URL") -# Extract the URLs of the assets named "pano-scrobbler-release.apk" and the corresponding tags +# Extract the URLs of the assets named "pano-scrobbler-release.apk", the corresponding tags, the created_at dates ASSET_URLS=$(echo "$JSON" | jq -r '.[] | select(.assets[0].name | endswith(".apk")) | .assets[0].browser_download_url') TAGS=$(echo "$JSON" | jq -r '.[] | select(.assets[0].name | endswith(".apk")) | .tag_name') +DATES=$(echo "$JSON" | jq -r '.[] | select(.assets[0].name | endswith(".apk")) | .created_at') -# Convert the URLs and tags to arrays +# Convert the URLs, tags, dates to arrays ASSET_URLS=($ASSET_URLS) TAGS=($TAGS) +DATES=($DATES) -# Download the last 5 assets +# Download the last 5 assets and create the changelogs +mkdir -p "metadata/${PACKAGE}/en-US/changelogs" for ((i=0; i<${#ASSET_URLS[@]} && i<5; i++)); do curl -L --create-dirs -o "repo/${REPO}-${TAGS[$i]}.apk" "${ASSET_URLS[$i]}" -done - -# create changelogs from github release body -mkdir -p "repo/${PACKAGE}/en-US/changelogs" -for ((i=0; i<${#ASSET_URLS[@]} && i<5; i++)); do - echo "Creating changelog for ${TAGS[$i]}" - echo -e "## ${TAGS[$i]}\n" > "repo/${PACKAGE}/en-US/changelogs/${TAGS[$i]}.txt" - curl -L "https://api.github.com/repos/$USER/$REPO/releases/tags/${TAGS[$i]}" | jq -r '.body' >> "repo/${PACKAGE}/en-US/changelogs/${TAGS[$i]}.txt" + touch -d "${DATES[$i]}" "repo/${REPO}-${TAGS[$i]}.apk" + CHANGELOG=$(echo "$JSON" | jq -r ".[$i] | .body") + echo -e "## ${TAGS[$i]}\n${CHANGELOG}" > "metadata/${PACKAGE}/en-US/changelogs/${TAGS[$i]}.txt" done # download screenshots -curl -L --create-dirs -o "repo/${PACKAGE}/en-US/phoneScreenshots/1scrobbles.png" "https://i.imgur.com/pgETfhc.png" -curl -L -o "repo/${PACKAGE}/en-US/phoneScreenshots/2friends.png" "https://i.imgur.com/Q7yPi2z.png" -curl -L -o "repo/${PACKAGE}/en-US/phoneScreenshots/3charts.png" "https://i.imgur.com/MUhcyBw.png" -curl -L -o "repo/${PACKAGE}/en-US/phoneScreenshots/4random.png" "https://i.imgur.com/aikbtGR.png" +curl -L --create-dirs -o "metadata/${PACKAGE}/en-US/phoneScreenshots/1scrobbles.png" "https://i.imgur.com/pgETfhc.png" +curl -L -o "metadata/${PACKAGE}/en-US/phoneScreenshots/2friends.png" "https://i.imgur.com/Q7yPi2z.png" +curl -L -o "metadata/${PACKAGE}/en-US/phoneScreenshots/3charts.png" "https://i.imgur.com/MUhcyBw.png" +curl -L -o "metadata/${PACKAGE}/en-US/phoneScreenshots/4random.png" "https://i.imgur.com/aikbtGR.png" # copy icon -cp ../../app/src/main/play/listings/en-US/icon/icon.png "repo/${PACKAGE}/en-US/icon.png" +cp ../../app/src/main/play/listings/en-US/icon/icon.png "metadata/${PACKAGE}/en-US/icon.png" # Run fdroid update -fdroid update --create-metadata +fdroid update --create-metadata --use-date-from-apk # Replace the default icon cp ../../app/src/main/play/listings/en-US/icon/icon.png repo/icons/icon.png