Nightly #410
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: Nightly | |
on: | |
schedule: | |
- cron: '0 4 * * *' | |
repository_dispatch: | |
types: [nightly] | |
workflow_dispatch: | |
jobs: | |
check-build-needed: | |
runs-on: ubuntu-latest | |
outputs: | |
build_nightly: ${{ steps.check.outputs.build_nightly }} | |
steps: | |
- uses: actions/checkout@v4 | |
- 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 | |
build-android: | |
needs: check-build-needed | |
if: ${{ needs.check-build-needed.outputs.build_nightly == 'true' }} | |
runs-on: ubuntu-latest | |
environment: release-build | |
container: | |
image: cimg/android:2023.11-node | |
options: -u root | |
env: | |
KEYSTORE_PATH: ${{ github.workspace }}/insporation.jks | |
steps: | |
- name: "Install SDK 33" | |
run: sdkmanager "build-tools;33.0.0" | |
- uses: actions/checkout@v4 | |
with: | |
ref: main # Ensure translations update is included | |
- uses: subosito/flutter-action@v2 | |
id: flutter-action | |
with: | |
flutter-version: '3.16.x' | |
- name: Workaround flutter directory permissions | |
run: |- | |
git config --global --add safe.directory ${{ steps.flutter-action.outputs.CACHE-PATH }} | |
git config --global --add safe.directory $(pwd) | |
- name: Setup keystore | |
run: | | |
echo "$KEYSTORE" | base64 -d > "$KEYSTORE_PATH" | |
env: | |
KEYSTORE: ${{ secrets.KEYSTORE }} | |
- name: Build | |
run: | | |
flutter build apk --release --build-number=$GITHUB_RUN_NUMBER | |
mkdir -p dist | |
cp build/app/outputs/apk/release/app-release.apk dist/insporation-nightly-$(git describe --tags 2>/dev/null || echo $GITHUB_RUN_NUMBER).apk | |
git rev-parse main > dist/BUILD_SHA | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
KEYSTORE_KEY_ALIAS: key | |
- uses: actions/upload-artifact@v1 | |
with: | |
name: Android Application bundles | |
path: dist | |
publish-android: | |
needs: build-android | |
runs-on: ubuntu-latest | |
environment: release-build | |
container: | |
image: registry.gitlab.com/fdroid/docker-executable-fdroidserver | |
env: | |
KEYSTORE_PATH: ${{ github.workspace }}/insporation.jks | |
LC_ALL: en_US.UTF-8 | |
LANG: en_US.UTF-8 | |
steps: | |
- uses: actions/download-artifact@v1 | |
with: | |
name: Android Application bundles | |
path: dist | |
- id: build_sha | |
run: echo "::set-output name=BUILD_SHA::$(cat dist/BUILD_SHA)" | |
- uses: marvinpinto/action-automatic-releases@latest | |
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/[email protected] | |
with: | |
files: 'dist/*' | |
release-tag: nightly | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout F-Droid repository | |
uses: actions/checkout@v4 | |
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 "[email protected]" | |
git config --local user.name "Github Actions Nightly Job" | |
# Truncate history | |
git checkout --orphan new-pages | |
git commit -m "Import previous state" | |
cd fdroid | |
# 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 $GITHUB_RUN_NUMBER" | |
git push -f "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.git" new-pages:gh-pages | |
shell: bash | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
KEYSTORE_KEY_ALIAS: key | |
- name: Trigger Github Pages deploy | |
uses: benc-uk/[email protected] | |
with: | |
workflow: pages.yml | |
ref: gh-pages | |
publish-ios: | |
needs: check-build-needed | |
if: ${{ needs.check-build-needed.outputs.build_nightly == 'true' }} | |
runs-on: macos-latest | |
environment: release-build | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: main # Ensure translations update is included | |
- uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.16.x' | |
- name: Build | |
run: | | |
flutter build ios --release --no-codesign --build-number=$GITHUB_RUN_NUMBER | |
cd ios | |
bundle config set deployment 'true' | |
bundle | |
bundle exec fastlane beta | |
env: | |
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} | |
MATCH_GIT_PRIVATE_KEY: ${{ secrets.MATCH_GIT_PRIVATE_KEY }} | |
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }} | |
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }} |