forked from firka/firka
The website's .apk button links to the newest main build, and main only published an .aab, which phones can't install.
233 lines
8.2 KiB
YAML
233 lines
8.2 KiB
YAML
when:
|
|
- event: [push, pull_request]
|
|
- event: manual
|
|
|
|
steps:
|
|
- name: submodules
|
|
image: git.firka.app/firka/firka-builder:latest
|
|
commands:
|
|
- git submodule update --init --recursive
|
|
|
|
- name: secrets
|
|
image: git.firka.app/firka/firka-builder:latest
|
|
environment:
|
|
UPLOAD_KEYSTORE_B64:
|
|
from_secret: upload_keystore_b64
|
|
KEYSTORE_PROPERTIES_B64:
|
|
from_secret: keystore_properties_b64
|
|
commands:
|
|
- echo "$UPLOAD_KEYSTORE_B64" | base64 -d > secrets/upload-keystore.jks
|
|
- echo "$KEYSTORE_PROPERTIES_B64" | base64 -d > secrets/keystore.properties
|
|
|
|
# Each step runs in a fresh container from the builder image -- only the
|
|
# workspace volume is shared between them. Pointing PUB_CACHE at a
|
|
# workspace-local dir (instead of the image's default /root/.pub-cache)
|
|
# is what lets `flutter pub get`'s downloads survive into later steps.
|
|
- name: dependencies
|
|
image: git.firka.app/firka/firka-builder:latest
|
|
commands:
|
|
- export PUB_CACHE="$CI_WORKSPACE/.pub-cache"
|
|
- cd firka
|
|
- '[ -f .env ] || cp .env.example .env 2>/dev/null || touch .env'
|
|
- flutter pub get
|
|
|
|
- name: codegen
|
|
image: git.firka.app/firka/firka-builder:latest
|
|
commands:
|
|
- export PUB_CACHE="$CI_WORKSPACE/.pub-cache"
|
|
- cd firka
|
|
- dart run scripts/codegen.dart
|
|
|
|
- name: clone-mock-kreta-server
|
|
image: git.firka.app/firka/firka-builder:latest
|
|
environment:
|
|
GITEA_USERNAME:
|
|
from_secret: gitea_username
|
|
GITEA_TOKEN:
|
|
from_secret: gitea_token
|
|
commands:
|
|
- pwd
|
|
# The heredoc uses a quoted delimiter so $GITEA_USERNAME/$GITEA_TOKEN
|
|
# are written to the script literally, not expanded here -- keeps the
|
|
# secret values out of this (traced) command's expanded output.
|
|
- |
|
|
cat > /tmp/write_netrc.sh <<'NETRC_SCRIPT'
|
|
printf 'machine git.firka.app\nlogin %s\npassword %s\n' "$GITEA_USERNAME" "$GITEA_TOKEN" > "$HOME/.netrc"
|
|
chmod 600 "$HOME/.netrc"
|
|
NETRC_SCRIPT
|
|
# Runs as an untraced child shell, so the expansion above never hits the log.
|
|
- sh /tmp/write_netrc.sh
|
|
- git clone --depth 1 https://git.firka.app/firka/mock_kreta_server.git mock_kreta_server
|
|
- rm -f /tmp/write_netrc.sh "$HOME/.netrc"
|
|
|
|
- name: build-mock-kreta-server
|
|
image: golang:1.26
|
|
commands:
|
|
- cd mock_kreta_server
|
|
- go build -o ../mock_kreta_server_bin .
|
|
|
|
# Runs the mock server in the background and exercises kreta_api's DTOs
|
|
# against its real wire format, catching drift between the two repos.
|
|
- name: kreta-api-mock-server-tests
|
|
image: git.firka.app/firka/firka-builder:latest
|
|
commands:
|
|
- export PUB_CACHE="$CI_WORKSPACE/.pub-cache"
|
|
- ./mock_kreta_server_bin -addr :8090 -data mock_kreta_server/data.json &
|
|
- sleep 1
|
|
- cd kreta_api
|
|
- dart pub get
|
|
- MOCK_KRETA_SERVER_URL=http://127.0.0.1:8090 dart test
|
|
|
|
- name: firka-e2e-tests
|
|
image: git.firka.app/firka/firka-builder:latest
|
|
commands:
|
|
- export PUB_CACHE="$CI_WORKSPACE/.pub-cache"
|
|
- ./mock_kreta_server_bin -addr :8090 -data mock_kreta_server/data.json &
|
|
- sleep 1
|
|
- cd firka
|
|
- '[ -f .env ] || cp .env.example .env 2>/dev/null || touch .env'
|
|
- cp $(find "$PUB_CACHE" -name libisar.so | grep linux | head -n 1) libisar.so 2>/dev/null || true
|
|
- flutter test test/data/widget_test.dart test/e2e/screenshot_widget_test.dart test/e2e/notification_diff_test.dart
|
|
|
|
- name: firka-integration-tests
|
|
image: git.firka.app/firka/firka-builder:latest
|
|
privileged: true
|
|
volumes:
|
|
- /dev/kvm:/dev/kvm
|
|
commands:
|
|
- export PUB_CACHE="$CI_WORKSPACE/.pub-cache"
|
|
- 'grep -q "::1" /etc/hosts || echo "::1 localhost ip6-localhost ip6-loopback" >> /etc/hosts 2>/dev/null || true'
|
|
- sysctl -w net.ipv6.conf.all.disable_ipv6=0 2>/dev/null || true
|
|
- sed -i 's/TIMEOUT=60/TIMEOUT=300/' /opt/bin/start-emulator.sh
|
|
- sed -i 's/-snapshot default_boot/-no-snapshot-load/' /opt/bin/start-emulator.sh
|
|
- ./mock_kreta_server_bin -addr :8090 -data mock_kreta_server/data.json &
|
|
- sleep 1
|
|
- /opt/bin/start-emulator.sh
|
|
- adb reverse tcp:8090 tcp:8090
|
|
- cd firka
|
|
- '[ -f .env ] || cp .env.example .env 2>/dev/null || touch .env'
|
|
- flutter test integration_test/widget_e2e_test.dart
|
|
|
|
- name: build-release
|
|
image: git.firka.app/firka/firka-builder:latest
|
|
when:
|
|
- branch: [main, staging]
|
|
commands:
|
|
- export PUB_CACHE="$CI_WORKSPACE/.pub-cache"
|
|
- cd firka
|
|
- '[ -f "$(git rev-parse --git-dir)/shallow" ] && git fetch --unshallow 2>/dev/null || true'
|
|
- SHA=$(git rev-parse --short HEAD)
|
|
- COMMIT_COUNT=$(git rev-list --count HEAD)
|
|
- 'BASE_VERSION=$(grep "^version:" pubspec.yaml | cut -d: -f2 | cut -d+ -f1 | tr -d " ")'
|
|
- BUILD_NAME="$BASE_VERSION-$SHA"
|
|
- VERSION_CODE=$((2000 + COMMIT_COUNT))
|
|
- flutter build appbundle --release --build-name="$BUILD_NAME" --build-number="$VERSION_CODE"
|
|
# universal apk for the website's download button, the .aab is for stores
|
|
- flutter build apk --release --build-name="$BUILD_NAME" --build-number="$VERSION_CODE"
|
|
|
|
- name: build-debug
|
|
image: git.firka.app/firka/firka-builder:latest
|
|
when:
|
|
- branch:
|
|
exclude: [main, staging]
|
|
commands:
|
|
- export PUB_CACHE="$CI_WORKSPACE/.pub-cache"
|
|
- cd firka
|
|
- '[ -f "$(git rev-parse --git-dir)/shallow" ] && git fetch --unshallow 2>/dev/null || true'
|
|
- SHA=$(git rev-parse --short HEAD)
|
|
- COMMIT_COUNT=$(git rev-list --count HEAD)
|
|
- 'BASE_VERSION=$(grep "^version:" pubspec.yaml | cut -d: -f2 | cut -d+ -f1 | tr -d " ")'
|
|
- BUILD_NAME="$BASE_VERSION-$SHA"
|
|
- VERSION_CODE=$((2000 + COMMIT_COUNT))
|
|
- flutter build apk --debug --split-per-abi --build-name="$BUILD_NAME" --build-number="$VERSION_CODE"
|
|
|
|
|
|
- name: publish-release
|
|
image: woodpeckercommunity/plugin-gitea-package:latest
|
|
pull: true
|
|
when:
|
|
- branch: [main, staging]
|
|
settings:
|
|
user:
|
|
from_secret: gitea_username
|
|
password:
|
|
from_secret: gitea_token
|
|
owner: firka
|
|
package_name: firka
|
|
package_version: ${CI_COMMIT_SHA}
|
|
file_source: ./firka/build/app/outputs/bundle/release/app-release.aab
|
|
file_name: app-release.aab
|
|
update: 'true'
|
|
|
|
- name: publish-release-apk
|
|
image: woodpeckercommunity/plugin-gitea-package:latest
|
|
pull: true
|
|
when:
|
|
- branch: [main, staging]
|
|
settings:
|
|
user:
|
|
from_secret: gitea_username
|
|
password:
|
|
from_secret: gitea_token
|
|
owner: firka
|
|
package_name: firka
|
|
package_version: ${CI_COMMIT_SHA}
|
|
file_source: ./firka/build/app/outputs/flutter-apk/app-release.apk
|
|
file_name: app-release.apk
|
|
update: 'true'
|
|
|
|
- name: publish-debug-arm64-v8a
|
|
image: woodpeckercommunity/plugin-gitea-package:latest
|
|
pull: true
|
|
when:
|
|
- branch:
|
|
exclude: [main, staging]
|
|
settings:
|
|
user:
|
|
from_secret: gitea_username
|
|
password:
|
|
from_secret: gitea_token
|
|
owner: firka
|
|
package_name: firka
|
|
package_version: ${CI_COMMIT_SHA}
|
|
file_source: ./firka/build/app/outputs/flutter-apk/app-arm64-v8a-debug.apk
|
|
file_name: app-arm64-v8a-debug.apk
|
|
update: 'true'
|
|
|
|
- name: publish-debug-armeabi-v7a
|
|
image: woodpeckercommunity/plugin-gitea-package:latest
|
|
pull: true
|
|
when:
|
|
- branch:
|
|
exclude: [main, staging]
|
|
settings:
|
|
user:
|
|
from_secret: gitea_username
|
|
password:
|
|
from_secret: gitea_token
|
|
owner: firka
|
|
package_name: firka
|
|
package_version: ${CI_COMMIT_SHA}
|
|
file_source: ./firka/build/app/outputs/flutter-apk/app-armeabi-v7a-debug.apk
|
|
file_name: app-armeabi-v7a-debug.apk
|
|
update: 'true'
|
|
|
|
- name: publish-debug-x86_64
|
|
image: woodpeckercommunity/plugin-gitea-package:latest
|
|
pull: true
|
|
when:
|
|
- branch:
|
|
exclude: [main, staging]
|
|
settings:
|
|
user:
|
|
from_secret: gitea_username
|
|
password:
|
|
from_secret: gitea_token
|
|
owner: firka
|
|
package_name: firka
|
|
package_version: ${CI_COMMIT_SHA}
|
|
file_source: ./firka/build/app/outputs/flutter-apk/app-x86_64-debug.apk
|
|
file_name: app-x86_64-debug.apk
|
|
update: 'true'
|
|
|