diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9cf17f2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,156 @@ +name: CI + +on: + schedule: + - cron: '01 0 * * *' # NIGHTLY @ 00:01 + workflow_dispatch: + push: + branches: + - main + +# taken from: kiwix/apple .github/workflows/cd.yml +env: + KEYCHAIN: /Users/runner/build.keychain-db + KEYCHAIN_PASSWORD: mysecretpassword + KEYCHAIN_PROFILE: build-profile + SSH_KEY: /tmp/id_rsa + APPLE_STORE_AUTH_KEY_PATH: /tmp/authkey.p8 + +jobs: + generate_build_deploy: + strategy: + fail-fast: false + matrix: + destination: + - platform: macOS + - platform: iOS + xcode_extra: -sdk iphoneos + runs-on: macos-13 + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + path: custom + + - name: Set test tag variable as an output + id: vars + run: echo "tag=test_2023.12.1" >> $GITHUB_OUTPUT + + - name: Validate and parse the tag + run: + | + cd custom + python src/tag_validator.py ${{ steps.vars.outputs.tag }} + cd .. + + - name: Check-out kiwix/apple + uses: actions/checkout@v4 + with: + repository: kiwix/apple + path: apple + + - name: Install Python dependencies for custom project generation + run: python -m pip install pyyaml + + - name: Install Kiwix dependencies + run: | # remove pre-commit, it's not needed for CI + cd apple + cat Brewfile | grep -v -e pre-commit > Brewfile_CI + brew bundle --force --file Brewfile_CI + cd .. + + - name: Generate project based on tag + env: + DWDS_HTTP_BASIC_ACCESS_AUTHENTICATION: ${{ secrets.DWDS_HTTP_BASIC_ACCESS_AUTHENTICATION }} + run: + | + # move the custom files under the same folder as the kiwix repo + mv custom/ apple/ + cd apple/custom + + # make a custom copy of the Info.plist file + cp ../Support/Info.plist Custom.plist + + python src/tag_validator.py ${{ steps.vars.outputs.tag }} + python src/generate_and_download.py + + # move the custom project file to the main folder + mv custom_project.yml ../ + cd .. + + # run xcodegen on our custom project + xcodegen -s custom_project.yml + + ls -la + + + - name: Set up scheme, version, build_number from files + run: | + # move the checked out github actions to root folder: + mv apple/.github/ . + + BRAND=$(<./apple/custom/.brand_name) + echo "BRAND=$BRAND" >> $GITHUB_ENV + + VERSION=$(<./apple/custom/.version_number) + echo "VERSION=$VERSION" >> $GITHUB_ENV + + # taken from: kiwix/apple .github/workflows/cd.yml + - name: Set up variables for build + env: + PLATFORM: ${{ matrix.destination.platform }} + EXTRA_XCODEBUILD: ${{ matrix.destination.xcode_extra }} + APPLE_STORE_AUTH_KEY_PATH: ${{ env.APPLE_STORE_AUTH_KEY_PATH }} + APPLE_STORE_AUTH_KEY_ID: ${{ secrets.APPLE_STORE_AUTH_KEY_ID }} + APPLE_STORE_AUTH_KEY_ISSUER_ID: ${{ secrets.APPLE_STORE_AUTH_KEY_ISSUER_ID }} + shell: python + run: | + import os + + extra_xcode = os.getenv("EXTRA_XCODEBUILD", "") + if os.getenv("PLATFORM") == "iOS": + extra_xcode += f" -authenticationKeyPath {os.getenv('APPLE_STORE_AUTH_KEY_PATH')}" + extra_xcode += f" -authenticationKeyID {os.getenv('APPLE_STORE_AUTH_KEY_ID')}" + extra_xcode += f" -authenticationKeyIssuerID {os.getenv('APPLE_STORE_AUTH_KEY_ISSUER_ID')}" + + with open(os.getenv("GITHUB_ENV"), "a") as fh: + fh.write(f"EXPORT_METHOD={'app-store'}\n") + fh.write(f"EXTRA_XCODEBUILD={extra_xcode}\n") + + - name: Prepare use of Apple Distribution Certificate + shell: bash + env: + APPLE_DISTRIBUTION_SIGNING_CERTIFICATE: ${{ secrets.APPLE_DISTRIBUTION_SIGNING_CERTIFICATE }} + APPLE_DISTRIBUTION_SIGNING_P12_PASSWORD: ${{ secrets.APPLE_DISTRIBUTION_SIGNING_P12_PASSWORD }} + APPLE_DEVELOPMENT_SIGNING_IDENTITY: ${{ secrets.APPLE_DEVELOPMENT_SIGNING_IDENTITY }} + run: | + echo "SIGNING_CERTIFICATE=${APPLE_DISTRIBUTION_SIGNING_CERTIFICATE}" >> "$GITHUB_ENV" + echo "SIGNING_CERTIFICATE_P12_PASSWORD=${APPLE_DISTRIBUTION_SIGNING_P12_PASSWORD}" >> "$GITHUB_ENV" + echo "SIGNING_IDENTITY=${APPLE_DEVELOPMENT_SIGNING_IDENTITY}" >> "$GITHUB_ENV" + + - name: Add Apple Store Key + env: + APPLE_STORE_AUTH_KEY_PATH: ${{ env.APPLE_STORE_AUTH_KEY_PATH }} + APPLE_STORE_AUTH_KEY: ${{ secrets.APPLE_STORE_AUTH_KEY }} + shell: bash + run: echo "${APPLE_STORE_AUTH_KEY}" | base64 --decode -o $APPLE_STORE_AUTH_KEY_PATH + + - name: Build xcarchive + uses: ./.github/actions/xcbuild + with: + action: archive + xc-destination: generic/platform=${{ matrix.destination.platform }} + # custom app specific + version: ${{ env.VERSION }} + XC_SCHEME: ${{ env.BRAND }} + DOWNLOAD_DEPENDENCIES: false + XC_WORKSPACE: apple/Kiwix.xcodeproj/project.xcworkspace/ + # eof custom app specific + APPLE_DEVELOPMENT_SIGNING_CERTIFICATE: ${{ secrets.APPLE_DEVELOPMENT_SIGNING_CERTIFICATE }} + APPLE_DEVELOPMENT_SIGNING_P12_PASSWORD: ${{ secrets.APPLE_DEVELOPMENT_SIGNING_P12_PASSWORD }} + DEPLOYMENT_SIGNING_CERTIFICATE: ${{ env.SIGNING_CERTIFICATE }} + DEPLOYMENT_SIGNING_CERTIFICATE_P12_PASSWORD: ${{ env.SIGNING_CERTIFICATE_P12_PASSWORD }} + KEYCHAIN: ${{ env.KEYCHAIN }} + KEYCHAIN_PASSWORD: ${{ env.KEYCHAIN_PASSWORD }} + KEYCHAIN_PROFILE: ${{ env.KEYCHAIN_PROFILE }} + EXTRA_XCODEBUILD: ${{ env.EXTRA_XCODEBUILD }} diff --git a/testapp/info.json b/testapp/info.json new file mode 100644 index 0000000..16b38df --- /dev/null +++ b/testapp/info.json @@ -0,0 +1,11 @@ +{ + "about_app_url": "https://www.kiwix.org/support", + "about_text": "CI Test Application", + "app_name": "TestApp", + "app_store_id": "id1281693200", + "enforced_lang": "en", + "settings_default_external_link_to": "alwaysLoad", + "settings_show_external_link_option": true, + "settings_show_search_snippet": false, + "zim_url": "https://dev.kiwix.org/apple/custom/test/wikipedia_en_ray_charles_maxi_2023-12.zim" +} diff --git a/testapp/testapp.xcassets/AppIcon.appiconset/Contents.json b/testapp/testapp.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..58285a8 --- /dev/null +++ b/testapp/testapp.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,74 @@ +{ + "images" : [ + { + "filename" : "test_1024.png", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + }, + { + "filename" : "test_16.png", + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "filename" : "test_32 1.png", + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "filename" : "test_32.png", + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "filename" : "test_64.png", + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "filename" : "test_128.png", + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "filename" : "test_256 1.png", + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "filename" : "test_256.png", + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "filename" : "test_512.png", + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "filename" : "test_512 1.png", + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "filename" : "test_1024 1.png", + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/testapp/testapp.xcassets/AppIcon.appiconset/test_1024 1.png b/testapp/testapp.xcassets/AppIcon.appiconset/test_1024 1.png new file mode 100644 index 0000000..2eeacde Binary files /dev/null and b/testapp/testapp.xcassets/AppIcon.appiconset/test_1024 1.png differ diff --git a/testapp/testapp.xcassets/AppIcon.appiconset/test_1024.png b/testapp/testapp.xcassets/AppIcon.appiconset/test_1024.png new file mode 100644 index 0000000..2eeacde Binary files /dev/null and b/testapp/testapp.xcassets/AppIcon.appiconset/test_1024.png differ diff --git a/testapp/testapp.xcassets/AppIcon.appiconset/test_128.png b/testapp/testapp.xcassets/AppIcon.appiconset/test_128.png new file mode 100644 index 0000000..2008da7 Binary files /dev/null and b/testapp/testapp.xcassets/AppIcon.appiconset/test_128.png differ diff --git a/testapp/testapp.xcassets/AppIcon.appiconset/test_16.png b/testapp/testapp.xcassets/AppIcon.appiconset/test_16.png new file mode 100644 index 0000000..d3cc118 Binary files /dev/null and b/testapp/testapp.xcassets/AppIcon.appiconset/test_16.png differ diff --git a/testapp/testapp.xcassets/AppIcon.appiconset/test_256 1.png b/testapp/testapp.xcassets/AppIcon.appiconset/test_256 1.png new file mode 100644 index 0000000..a3df6d7 Binary files /dev/null and b/testapp/testapp.xcassets/AppIcon.appiconset/test_256 1.png differ diff --git a/testapp/testapp.xcassets/AppIcon.appiconset/test_256.png b/testapp/testapp.xcassets/AppIcon.appiconset/test_256.png new file mode 100644 index 0000000..a3df6d7 Binary files /dev/null and b/testapp/testapp.xcassets/AppIcon.appiconset/test_256.png differ diff --git a/testapp/testapp.xcassets/AppIcon.appiconset/test_32 1.png b/testapp/testapp.xcassets/AppIcon.appiconset/test_32 1.png new file mode 100644 index 0000000..48fce72 Binary files /dev/null and b/testapp/testapp.xcassets/AppIcon.appiconset/test_32 1.png differ diff --git a/testapp/testapp.xcassets/AppIcon.appiconset/test_32.png b/testapp/testapp.xcassets/AppIcon.appiconset/test_32.png new file mode 100644 index 0000000..48fce72 Binary files /dev/null and b/testapp/testapp.xcassets/AppIcon.appiconset/test_32.png differ diff --git a/testapp/testapp.xcassets/AppIcon.appiconset/test_512 1.png b/testapp/testapp.xcassets/AppIcon.appiconset/test_512 1.png new file mode 100644 index 0000000..76b8b62 Binary files /dev/null and b/testapp/testapp.xcassets/AppIcon.appiconset/test_512 1.png differ diff --git a/testapp/testapp.xcassets/AppIcon.appiconset/test_512.png b/testapp/testapp.xcassets/AppIcon.appiconset/test_512.png new file mode 100644 index 0000000..76b8b62 Binary files /dev/null and b/testapp/testapp.xcassets/AppIcon.appiconset/test_512.png differ diff --git a/testapp/testapp.xcassets/AppIcon.appiconset/test_64.png b/testapp/testapp.xcassets/AppIcon.appiconset/test_64.png new file mode 100644 index 0000000..8e2226a Binary files /dev/null and b/testapp/testapp.xcassets/AppIcon.appiconset/test_64.png differ diff --git a/testapp/testapp.xcassets/Contents.json b/testapp/testapp.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/testapp/testapp.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/testapp/testapp.xcassets/GenericZimFile.imageset/Contents.json b/testapp/testapp.xcassets/GenericZimFile.imageset/Contents.json new file mode 100644 index 0000000..e577b37 --- /dev/null +++ b/testapp/testapp.xcassets/GenericZimFile.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "icon_128x128.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/testapp/testapp.xcassets/GenericZimFile.imageset/icon_128x128.png b/testapp/testapp.xcassets/GenericZimFile.imageset/icon_128x128.png new file mode 100644 index 0000000..7febc9a Binary files /dev/null and b/testapp/testapp.xcassets/GenericZimFile.imageset/icon_128x128.png differ diff --git a/testapp/testapp.xcassets/Other.imageset/Contents.json b/testapp/testapp.xcassets/Other.imageset/Contents.json new file mode 100644 index 0000000..c6a628d --- /dev/null +++ b/testapp/testapp.xcassets/Other.imageset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { + "filename" : "notebook.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true + } +} diff --git a/testapp/testapp.xcassets/Other.imageset/notebook.svg b/testapp/testapp.xcassets/Other.imageset/notebook.svg new file mode 100644 index 0000000..862e953 --- /dev/null +++ b/testapp/testapp.xcassets/Other.imageset/notebook.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testapp/testapp.xcassets/StarAdd.imageset/BookmarkAdded.png b/testapp/testapp.xcassets/StarAdd.imageset/BookmarkAdded.png new file mode 100644 index 0000000..d2d0e65 Binary files /dev/null and b/testapp/testapp.xcassets/StarAdd.imageset/BookmarkAdded.png differ diff --git a/testapp/testapp.xcassets/StarAdd.imageset/Contents.json b/testapp/testapp.xcassets/StarAdd.imageset/Contents.json new file mode 100644 index 0000000..98137d0 --- /dev/null +++ b/testapp/testapp.xcassets/StarAdd.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "BookmarkAdded.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/testapp/testapp.xcassets/StarRemove.imageset/BookmarkRemoved.png b/testapp/testapp.xcassets/StarRemove.imageset/BookmarkRemoved.png new file mode 100644 index 0000000..96fa66b Binary files /dev/null and b/testapp/testapp.xcassets/StarRemove.imageset/BookmarkRemoved.png differ diff --git a/testapp/testapp.xcassets/StarRemove.imageset/Contents.json b/testapp/testapp.xcassets/StarRemove.imageset/Contents.json new file mode 100644 index 0000000..7e508a6 --- /dev/null +++ b/testapp/testapp.xcassets/StarRemove.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "BookmarkRemoved.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/testapp/testapp.xcassets/welcomeLogo.imageset/Contents.json b/testapp/testapp.xcassets/welcomeLogo.imageset/Contents.json new file mode 100644 index 0000000..e448066 --- /dev/null +++ b/testapp/testapp.xcassets/welcomeLogo.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "test_243.png", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "original" + } +} diff --git a/testapp/testapp.xcassets/welcomeLogo.imageset/test_243.png b/testapp/testapp.xcassets/welcomeLogo.imageset/test_243.png new file mode 100644 index 0000000..60ad496 Binary files /dev/null and b/testapp/testapp.xcassets/welcomeLogo.imageset/test_243.png differ