Generate F-Droid repo #148
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: Generate F-Droid repo | |
on: | |
workflow_dispatch: | |
inputs: | |
dry-run: | |
description: "Skips pushing changes when enabled. Optional. Defaults to false." | |
type: boolean | |
default: false | |
required: false | |
max-items: | |
description: "Maximum number of items to convert. Optional. Defaults to all." | |
type: number | |
required: false | |
default: 0 | |
schedule: | |
- cron: "45 2 * * *" | |
push: | |
paths: | |
- '.github/workflows/fdroid.yml' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
apps: | |
name: "Generate repo from apps listing" | |
runs-on: ubuntu-24.04 | |
env: | |
COMMIT_MSG_FILE: "${{ github.workspace }}/commit_message.tmp" | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 | |
- name: Create basic directory structure | |
run: mkdir -p fdroid/repo | |
- name: Restore correct mtime | |
run: | | |
sudo apt install git-restore-mtime | |
git restore-mtime | |
- name: Set up Git | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "35998162" | |
- name: Set up repo secrets | |
run: | | |
echo "${{ secrets.KEYSTORE_P12 }}" | base64 -d - > fdroid/keystore.p12 | |
- name: Validate secrets | |
run: | | |
if [ -f "fdroid/keystore.p12" ]; then | |
echo "keystore found" | |
else | |
echo "keystore not found!" | |
exit 1 | |
fi | |
- name: Configure F-Droid server | |
env: | |
FDROID_STORE_KEYSTORE_PASSWORD: ${{ secrets.FDROID_STORE_KEYSTORE_PASSWORD }} | |
run: | | |
cp base_fdroid_config.yml fdroid/config.yml | |
chmod 0600 fdroid/config.yml | |
echo "keypass: '$FDROID_STORE_KEYSTORE_PASSWORD'" >> fdroid/config.yml | |
echo "keystorepass: '$FDROID_STORE_KEYSTORE_PASSWORD'" >> fdroid/config.yml | |
# Get repo and replace [GithubRepo] with the actual repo | |
repo=$(echo "${{ github.repository }}" | sed 's/\//\\\//g') | |
sed -i "s/\[GithubRepo\]/$repo/g" fdroid/config.yml | |
- name: Add apt repository | |
run: | | |
sudo add-apt-repository ppa:fdroid/fdroidserver | |
sudo apt-get update | |
- name: Cache apt packages | |
id: cache-apt-packages | |
uses: awalsh128/cache-apt-pkgs-action@latest | |
with: | |
packages: fdroidserver | |
version: "@latest" | |
continue-on-error: true | |
- name: Install apt packages if cache fails | |
if: steps.cache-apt-packages.outcome != 'success' | |
run: | | |
sudo apt-get install -y fdroidserver | |
- name: Fix androidguard | |
run: | | |
sudo sed -i 's|raise ResParserError("res0 must be zero!")|log.warning("res0 must be zero!")|g' /usr/lib/python3/dist-packages/androguard/core/bytecodes/axml/__init__.py | |
sudo sed -i 's|raise ResParserError("res1 must be zero!")|log.warning("res1 must be zero!")|g' /usr/lib/python3/dist-packages/androguard/core/bytecodes/axml/__init__.py | |
- name: Set up Go | |
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | |
with: | |
go-version: '^1.17.0' | |
- name: Download modules.json and convert | |
working-directory: convert_xposed | |
run: | | |
num_items=${{ inputs.max-items }} | |
if [ -z "$num_items" ]; then | |
num_items=0 | |
fi | |
go run main_convert.go -o ../repos.yaml -max $num_items | |
- name: Run metascoop | |
id: run-metascoop | |
env: | |
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |
run: | | |
bash run_metascoop.sh ${{ env.COMMIT_MSG_FILE }} | |
if [ $? -eq 0 ]; then | |
echo "Changes detected" | |
echo "has_changes=true" >> $GITHUB_OUTPUT | |
elif [ $? -eq 2 ]; then | |
echo "No changes detected" | |
echo "has_changes=false" >> $GITHUB_OUTPUT | |
else | |
echo "Unexpected exit code: $?" | |
echo "has_changes=false" >> $GITHUB_OUTPUT | |
fi | |
continue-on-error: true | |
- name: Delete F-Droid server config | |
run: | | |
rm -f fdroid/config.yml | |
- name: Update repo | |
env: | |
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |
run: | | |
if [ "${{ inputs.dry-run }}" = "true" ]; then | |
echo "Dry run. Changes are not being saved." | |
elif [ "${{ steps.run-metascoop.outputs.has_changes }}" != "true" ]; then | |
echo "No changes to save." | |
else | |
bash update_repo.sh ${{ env.COMMIT_MSG_FILE }} | |
fi |