Nightly #491
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: Nightly | |
| on: | |
| schedule: | |
| - cron: '0 4 * * *' | |
| repository_dispatch: | |
| types: [nightly] | |
| workflow_dispatch: | |
| concurrency: | |
| group: build-number | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| check-build-needed: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| build_nightly: ${{ steps.check.outputs.build_nightly }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - id: check | |
| run: | | |
| git fetch --depth=1 --no-tags origin +refs/tags/nightly:refs/tags/nightly | |
| [ "$GITHUB_EVENT_NAME" != "schedule" -o "$(git show-ref -s --head HEAD)" != "$(git show-ref -s nightly)" ] && echo build_nightly=true >> $GITHUB_OUTPUT | |
| exit 0 | |
| determine-build-number: | |
| needs: check-build-needed | |
| if: ${{ needs.check-build-needed.outputs.build_nightly == 'true' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| outputs: | |
| value: ${{ steps.build_number.outputs.value }} | |
| steps: | |
| - name: Determine shared build number | |
| id: build_number | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| nightly=$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/nightly.yml/runs?status=completed&per_page=1" --jq '.workflow_runs[0].run_number') | |
| release=$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/release.yml/runs?status=completed&per_page=1" --jq '.workflow_runs[0].run_number') | |
| next=$((nightly + release + 1)) | |
| echo "value=$next" >> "$GITHUB_OUTPUT" | |
| build-android: | |
| needs: [check-build-needed, determine-build-number] | |
| if: ${{ needs.check-build-needed.outputs.build_nightly == 'true' }} | |
| runs-on: ubuntu-latest | |
| environment: release-build | |
| container: | |
| image: cimg/android:2026.03.1-node | |
| options: -u root | |
| env: | |
| KEYSTORE_PATH: ${{ github.workspace }}/insporation.jks | |
| steps: | |
| - name: "Install SDK 36 build tools" | |
| run: sdkmanager "build-tools;36.0.0" | |
| - uses: actions/checkout@v7 | |
| with: | |
| ref: main # Ensure translations update is included | |
| - uses: subosito/flutter-action@v2 | |
| id: flutter-action | |
| with: | |
| flutter-version: '3.41.x' | |
| channel: stable | |
| - name: Workaround flutter directory permissions | |
| run: |- | |
| git config --global --add safe.directory ${{ steps.flutter-action.outputs.CACHE-PATH }} | |
| git config --global --add safe.directory ${{ steps.flutter-action.outputs.CACHE-PATH }}/flutter | |
| git config --global --add safe.directory $(pwd) | |
| - name: Setup keystore | |
| run: | | |
| echo "$KEYSTORE" | base64 -d > "$KEYSTORE_PATH" | |
| env: | |
| KEYSTORE: ${{ secrets.KEYSTORE }} | |
| - name: Build | |
| run: | | |
| BUILD_COMMIT="$(git rev-parse HEAD)" | |
| BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" | |
| flutter build apk --release --build-number=${{ needs.determine-build-number.outputs.value }} --dart-define=BUILD_COMMIT=$BUILD_COMMIT --dart-define=BUILD_DATE=$BUILD_DATE | |
| mkdir -p dist | |
| cp build/app/outputs/apk/release/app-release.apk dist/insporation-nightly-$(git describe --tags 2>/dev/null || echo ${{ needs.determine-build-number.outputs.value }}).apk | |
| git rev-parse main > dist/BUILD_SHA | |
| env: | |
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
| KEYSTORE_KEY_ALIAS: key | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: Android Application bundles | |
| path: dist | |
| publish-android: | |
| needs: [build-android, determine-build-number] | |
| runs-on: ubuntu-latest | |
| environment: release-build | |
| permissions: | |
| contents: write | |
| actions: write | |
| container: | |
| image: registry.gitlab.com/fdroid/docker-executable-fdroidserver:master | |
| env: | |
| KEYSTORE_PATH: ${{ github.workspace }}/insporation.jks | |
| LC_ALL: en_US.UTF-8 | |
| LANG: en_US.UTF-8 | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: Android Application bundles | |
| path: dist | |
| - id: build_sha | |
| run: echo "BUILD_SHA=$(cat dist/BUILD_SHA)" >> $GITHUB_OUTPUT | |
| - uses: tomasbkk/action-automatic-releases@v1.2.2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| automatic_release_tag: nightly | |
| env: | |
| GITHUB_SHA: ${{ steps.build_sha.outputs.BUILD_SHA }} # Ensure translations update is included | |
| - uses: AButler/upload-release-assets@v4.0 | |
| with: | |
| files: 'dist/*' | |
| release-tag: nightly | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Checkout F-Droid repository | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: gh-pages | |
| path: pages | |
| - name: Setup keystore | |
| run: | | |
| echo "$KEYSTORE" | base64 -d > "$KEYSTORE_PATH" | |
| env: | |
| KEYSTORE: ${{ secrets.KEYSTORE }} | |
| - name: Update F-Droid repository | |
| run: | | |
| . /etc/profile.d/bsenv.sh | |
| cd pages | |
| git config --local user.email "me+nightly-ci@jhass.eu" | |
| git config --local user.name "Github Actions Nightly Job" | |
| # Truncate history | |
| git checkout --orphan new-pages | |
| git commit -m "Import previous state" | |
| cd fdroid-nightly | |
| # Add new build | |
| cp ../../dist/*.apk repo/ | |
| # Cleanup archive | |
| find archive -name '*.apk' | sort -V | head -n-2 | xargs -r rm | |
| # Rebuild repos | |
| ${fdroidserver}/fdroid update | |
| # Cleanup icons | |
| for icon in {repo,archive}/icons/*.*.png; do | |
| repo="$(dirname "$(dirname "$icon")")" | |
| base="$(basename "$icon" .png)" | |
| build="$(echo "$base" | tr -Cd '0-9')" | |
| if [ ! -e "$repo/insporation-nightly-$build.apk" ]; then | |
| rm $repo/icons*/$base.{png,xml} || echo "No icons for $repo/$base.apk present" | |
| fi | |
| done | |
| # Publish | |
| git add . | |
| git commit -m "Update fdroid repository for nightly build $BUILD_NUMBER" | |
| git push -f "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" new-pages:gh-pages | |
| shell: bash | |
| env: | |
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
| KEYSTORE_KEY_ALIAS: key | |
| BUILD_NUMBER: ${{ needs.determine-build-number.outputs.value }} | |
| - name: Trigger Github Pages deploy | |
| uses: benc-uk/workflow-dispatch@v1 | |
| with: | |
| workflow: pages.yml | |
| ref: gh-pages |