Clarify latest build and signed release status #14
This file contains hidden or 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 APK | |
| on: | |
| push: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: claimboard-build-main | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| - name: Reconstruct base source | |
| shell: bash | |
| run: | | |
| cat .ci/source.b64.* > source.b64 | |
| base64 -d source.b64 > ClaimBoard-Scanner-base-source.zip | |
| unzip -t ClaimBoard-Scanner-base-source.zip | |
| mkdir project | |
| unzip -q ClaimBoard-Scanner-base-source.zip -d project | |
| chmod +x project/build.sh project/verify.sh | |
| - name: Apply current source patches | |
| shell: bash | |
| run: | | |
| cd project | |
| patch -p0 < ../patches/claimboard-0.3.1.patch | |
| sed -i 's/android:versionCode="3"/android:versionCode="4"/' AndroidManifest.xml | |
| sed -i 's/android:versionName="0.3.0"/android:versionName="0.3.1"/' AndroidManifest.xml | |
| sed -i 's/"appVersion", "0.3.0"/"appVersion", "0.3.1"/' src/it/claimboard/scanner/ClaimDataStore.java | |
| sed -i 's/Versione 0.3.0 · scansione automatica/Versione 0.3.1 · scansione automatica/' src/it/claimboard/scanner/MainActivity.java | |
| sed -i 's/ClaimBoard-Scanner-0.3.0-aligned-unsigned.apk/ClaimBoard-Scanner-0.3.1-aligned-unsigned.apk/g' build.sh | |
| sed -i 's/ClaimBoard-Scanner-0.3.0.apk/ClaimBoard-Scanner-0.3.1.apk/g' build.sh | |
| - name: Detect compiled version | |
| shell: bash | |
| run: | | |
| VERSION=$(sed -n 's/.*android:versionName="\([^"]*\)".*/\1/p' project/AndroidManifest.xml | head -n1) | |
| test -n "$VERSION" | |
| echo "VERSION=$VERSION" >> "$GITHUB_ENV" | |
| echo "Compiling ClaimBoard Scanner $VERSION" | |
| - name: Ensure Android SDK packages | |
| shell: bash | |
| run: | | |
| yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses >/dev/null || true | |
| "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "platforms;android-35" "build-tools;35.0.0" | |
| - name: Patch D8 input for current Build Tools | |
| shell: bash | |
| run: | | |
| python3 - <<'PY' | |
| p = 'project/build.sh' | |
| s = open(p, encoding='utf-8').read() | |
| old = '"$d8" --min-api 23 --output "$build_dir/dex" "$build_dir/classes"' | |
| new = '"$d8" --min-api 23 --output "$build_dir/dex" $(find "$build_dir/classes" -type f -name \'*.class\')' | |
| if old not in s: | |
| raise SystemExit('Expected D8 command not found') | |
| open(p, 'w', encoding='utf-8').write(s.replace(old, new)) | |
| PY | |
| - name: Build aligned unsigned APK | |
| working-directory: project | |
| run: ./build.sh | |
| - name: Stage signing tool | |
| shell: bash | |
| run: | | |
| mkdir -p project/build/signing-tool | |
| cp "$ANDROID_HOME/build-tools/35.0.0/lib/apksigner.jar" project/build/signing-tool/ | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: claimboard-${{ env.VERSION }}-unsigned | |
| path: | | |
| project/build/outputs/ClaimBoard-Scanner-${{ env.VERSION }}-aligned-unsigned.apk | |
| project/build/signing-tool/apksigner.jar | |
| if-no-files-found: error | |
| - name: Sync README version badge | |
| if: github.ref == 'refs/heads/main' | |
| shell: bash | |
| run: | | |
| python3 - <<'PY' | |
| import json, os | |
| version = os.environ['VERSION'] | |
| data = { | |
| 'schemaVersion': 1, | |
| 'label': 'current version', | |
| 'message': version, | |
| 'color': 'blue' | |
| } | |
| with open('version-badge.json', 'w', encoding='utf-8') as f: | |
| json.dump(data, f, separators=(',', ':')) | |
| f.write('\n') | |
| PY | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add version-badge.json | |
| if ! git diff --cached --quiet; then | |
| git commit -m "chore: sync current version ${VERSION}" | |
| git push origin HEAD:main | |
| fi |