Update #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update | |
on: | |
schedule: | |
- cron: '35 0 * * *' | |
workflow_dispatch: | |
inputs: | |
force_update: | |
type: boolean | |
description: 'Force update/build' | |
default: false | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
permissions: | |
contents: write | |
jobs: | |
check-for-update: | |
runs-on: ubuntu-latest | |
outputs: | |
requires_update: ${{ steps.check.outputs.requires_update }} | |
latest_version: ${{ steps.check.outputs.latest_version }} | |
latest_version_download_url: ${{ steps.check.outputs.latest_version_download_url }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: check | |
run: | | |
latest_release_data=$(curl -L https://api.github.com/repos/MaintainTeam/LastPipeBender/releases/latest) | |
latest_release_name=$(echo "$latest_release_data" | jq -r '.name') | |
echo "Latest version is '$latest_release_name'" | |
current_deployed_release=$(cat current.txt || echo "") | |
echo "Currently deployed version is '$current_deployed_release'" | |
echo "Force update is '${{ inputs.force_update }}'" | |
if [[ "${{ inputs.force_update }}" != "true" && "$latest_release_name" == "$current_deployed_release" ]]; then | |
echo "requires_update=false" >> "$GITHUB_OUTPUT" | |
exit 0 | |
fi | |
echo "requires_update=true" >> "$GITHUB_OUTPUT" | |
echo "latest_version=$latest_release_name" >> "$GITHUB_OUTPUT" | |
# TODO: ADD OTHER VERSIONS LATER | |
latest_version_download_url=$(echo "$latest_release_data" | grep "browser_download_url.*extended.*apk" | cut -d : -f 2,3 | tr -d \" ) | |
echo "Latest version download url is '$latest_version_download_url'" | |
echo "latest_version_download_url=$latest_version_download_url" >> "$GITHUB_OUTPUT" | |
update: | |
runs-on: ubuntu-latest | |
needs: check-for-update | |
if: needs.check-for-update.outputs.requires_update == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download assets | |
run: | | |
mkdir -p apks | |
echo "Downloading latest version" | |
echo "${{ needs.check-for-update.outputs.latest_version_download_url }}" | wget -P apks --no-verbose -i - | |
echo "Downloading recent releases" | |
curl -L https://api.github.com/repos/MaintainTeam/LastPipeBender/releases?per_page=5 \ | |
| jq -r '.[].assets[].browser_download_url' \ | |
| while read -r url; do wget -P apks --no-verbose $url; done | |
# Delete renamed apks | |
(cd apks && find . -type f ! -name '*.apk' -delete) | |
ls -lha apks | |
- name: Load KeyStore file | |
run: echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d - > repo/keystore.p12 | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- name: Build F-Droid Repo Generator | |
uses: docker/build-push-action@v6 | |
with: | |
context: ./fdroid-repo-generator | |
load: true | |
tags: fdroid-repo-generator | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Write index.html | |
run: | | |
mkdir -p deploy | |
cat <<EOF >> deploy/index.html | |
<html> | |
<head> | |
<meta http-equiv="refresh" content="0; url=fdroid/repo" /> | |
</head> | |
<body> | |
<p><a href="fdroid/repo">Click here if redirect is not working</a></p> | |
</body> | |
</html> | |
EOF | |
- name: Run F-Droid Repo Generator | |
run: | | |
docker run --rm \ | |
-v $(pwd)/apks:/apks \ | |
-v $(pwd)/deploy:/deploy \ | |
-v $(pwd)/repo:/repobase \ | |
-w /repo \ | |
-e REPO_KEYALIAS="${{ secrets.REPO_KEYALIAS }}" \ | |
-e KEYSTOREPASS="${{ secrets.KEYSTOREPASS }}" \ | |
-e KEYPASS="${{ secrets.KEYPASS }}" \ | |
-e KEYDNAME="${{ secrets.KEYDNAME }}" \ | |
fdroid-repo-generator | |
- name: Deploy to Github pages | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./deploy | |
force_orphan: true | |
# WILL BE ADDED LATER | |
# mirror: | |
# runs-on: ubuntu-latest | |
# needs: [check-for-update, update] | |
# steps: | |
# - run: | | |
# git clone --bare https://github.com/litetex/fdroid-pages.git --single-branch --branch gh-pages | |
# cd fdroid-pages.git | |
# echo "Renaming branch" | |
# git branch -m gh-pages pages | |
# echo "Starting push" | |
# git push --mirror https://litetex:${{ secrets.CB_TOKEN }}@codeberg.org/litetex/fdroid-pages.git | |
# echo "Done" | |
track-current-version: | |
runs-on: ubuntu-latest | |
needs: [check-for-update, update] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Init Git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
- name: Update currently deployed version | |
run: | | |
echo "${{ needs.check-for-update.outputs.latest_version }}" > current.txt | |
- name: Push update | |
run: | | |
git add -A | |
git commit -m "Update version to ${{ needs.check-for-update.outputs.latest_version }}" && git push || true |