Build App Packages and Collect App Information #13
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: Build App Packages | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * *" # Run daily at midnight | |
jobs: | |
build: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PAT }} | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests | |
- name: Make scrapers executable | |
run: chmod +x .github/scripts/scrapers/*.sh | |
- name: Collect app information | |
run: python .github/scripts/collect_app_info.py | |
- name: Find apps needing packaging | |
id: find-apps | |
run: | | |
echo "Finding apps that need special packaging..." | |
apps_to_build=() | |
for file in Apps/*.json; do | |
if [ -f "$file" ]; then | |
type=$(jq -r '.type // empty' "$file") | |
if [ "$type" = "app" ]; then | |
app_name=$(basename "$file" .json) | |
url=$(jq -r '.url' "$file") | |
apps_to_build+=("$app_name:$url") | |
fi | |
fi | |
done | |
echo "APPS_TO_BUILD=${apps_to_build[*]}" >> $GITHUB_ENV | |
echo "Found apps: ${apps_to_build[*]}" | |
- name: Commit and push changes | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add Apps/*.json supported_apps.json README.md | |
git commit -m "Update app information and supported apps list" || exit 0 | |
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git | |
- name: Process apps | |
if: env.APPS_TO_BUILD != '' | |
env: | |
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }} | |
run: | | |
WORKSPACE_DIR=$(pwd) | |
for app_info in $APPS_TO_BUILD; do | |
IFS=':' read -r app_name url <<< "$app_info" | |
echo "Processing $app_name..." | |
# Get version from JSON file | |
version=$(jq -r '.version' "$WORKSPACE_DIR/Apps/${app_name}.json") | |
echo "Version: $version" | |
# Check if package already exists in Azure | |
if az storage blob exists --container-name pkg --name "${app_name}_${version}.pkg" --query "exists" --output tsv | grep -q "true"; then | |
echo "Package ${app_name}_${version}.pkg already exists in Azure storage. Skipping..." | |
continue | |
fi | |
# Download app | |
echo "Downloading $app_name..." | |
curl -L -o ~/Desktop/${app_name}.zip "$url" | |
# Unzip app | |
echo "Unzipping $app_name..." | |
cd ~/Desktop | |
unzip -q ${app_name}.zip | |
# Find .app file | |
app_file=$(find . -maxdepth 2 -name "*.app" -print -quit) | |
if [ -z "$app_file" ]; then | |
echo "No .app file found for $app_name" | |
cd "$WORKSPACE_DIR" | |
continue | |
fi | |
# Build PKG with version in filename | |
echo "Building PKG for $app_name version $version..." | |
pkgbuild --install-location /Applications --component "$app_file" "${app_name}_${version}.pkg" | |
# Upload to Azure with version in filename | |
echo "Uploading $app_name version $version to Azure Blob Storage..." | |
az storage blob upload \ | |
--container-name pkg \ | |
--file "${app_name}_${version}.pkg" \ | |
--name "${app_name}_${version}.pkg" \ | |
--overwrite true | |
# Cleanup | |
rm -f ${app_name}.zip ${app_name}_${version}.pkg | |
rm -rf *.app | |
# Return to workspace directory | |
cd "$WORKSPACE_DIR" | |
echo "Completed processing $app_name version $version" | |
done |