mirror of
https://gitlab.com/foxixus/neomovies_mobile.git
synced 2025-10-27 22:38:50 +05:00
fix ci/cd
This commit is contained in:
138
.gitlab-ci.yml
138
.gitlab-ci.yml
@@ -1,35 +1,135 @@
|
||||
image: ghcr.io/cirruslabs/flutter:beta
|
||||
stages:
|
||||
- test
|
||||
- build
|
||||
- deploy
|
||||
|
||||
stages: [build]
|
||||
variables:
|
||||
FLUTTER_VERSION: "3.16.0"
|
||||
ANDROID_SDK_VERSION: "34"
|
||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
||||
|
||||
# Кэш для оптимизации сборки
|
||||
cache:
|
||||
key: $CI_JOB_NAME
|
||||
key: flutter-cache
|
||||
paths:
|
||||
- .pub-cache
|
||||
- build
|
||||
- .pub-cache/
|
||||
- android/.gradle/
|
||||
- build/
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
build_android:
|
||||
image: ghcr.io/cirruslabs/flutter:beta-android # уже содержит SDK
|
||||
stage: build
|
||||
script:
|
||||
# Тестирование
|
||||
test:
|
||||
stage: test
|
||||
image: cirrusci/flutter:${FLUTTER_VERSION}
|
||||
before_script:
|
||||
- flutter --version
|
||||
- flutter pub get
|
||||
- flutter build apk --release --dart-define=ENV=production
|
||||
script:
|
||||
- flutter analyze
|
||||
- flutter test
|
||||
artifacts:
|
||||
reports:
|
||||
junit: test-results.xml
|
||||
paths:
|
||||
- coverage/
|
||||
expire_in: 1 week
|
||||
|
||||
# Сборка Android APK
|
||||
build_android:
|
||||
stage: build
|
||||
image: cirrusci/flutter:${FLUTTER_VERSION}
|
||||
before_script:
|
||||
- flutter --version
|
||||
- flutter pub get
|
||||
script:
|
||||
- flutter build apk --release
|
||||
- flutter build appbundle --release
|
||||
artifacts:
|
||||
paths:
|
||||
- build/app/outputs/flutter-apk/app-release.apk
|
||||
expire_in: 1 week
|
||||
- build/app/outputs/bundle/release/app-release.aab
|
||||
expire_in: 1 month
|
||||
only:
|
||||
- main
|
||||
- develop
|
||||
- tags
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# Сборка Linux приложения
|
||||
build_linux:
|
||||
stage: build
|
||||
image: ubuntu:22.04
|
||||
before_script:
|
||||
# Cirrus image уже имеет GTK и CMake; добавляем dev-libs для plugins
|
||||
- apt-get update && apt-get install -y libjsoncpp-dev libsecret-1-dev
|
||||
script:
|
||||
- apt-get update -y
|
||||
- apt-get install -y curl git unzip xz-utils zip libglu1-mesa
|
||||
- apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev
|
||||
- apt-get install -y libblkid-dev liblzma-dev
|
||||
# Установка Flutter
|
||||
- git clone https://github.com/flutter/flutter.git -b stable --depth 1
|
||||
- export PATH="$PATH:`pwd`/flutter/bin"
|
||||
- flutter --version
|
||||
- flutter config --enable-linux-desktop
|
||||
- flutter pub get
|
||||
- flutter build linux --release --dart-define=ENV=production
|
||||
script:
|
||||
- flutter build linux --release
|
||||
artifacts:
|
||||
paths:
|
||||
- build/linux/**/release/bundle
|
||||
expire_in: 1 week
|
||||
- build/linux/x64/release/bundle/
|
||||
expire_in: 1 month
|
||||
only:
|
||||
- main
|
||||
- develop
|
||||
- tags
|
||||
|
||||
# Деплой в Google Play (опционально)
|
||||
deploy_android:
|
||||
stage: deploy
|
||||
image: ruby:3.0
|
||||
before_script:
|
||||
- gem install fastlane
|
||||
script:
|
||||
- cd android
|
||||
- fastlane supply --aab ../build/app/outputs/bundle/release/app-release.aab
|
||||
dependencies:
|
||||
- build_android
|
||||
only:
|
||||
- tags
|
||||
when: manual
|
||||
|
||||
# Деплой Linux приложения в GitLab Package Registry
|
||||
deploy_linux:
|
||||
stage: deploy
|
||||
image: ubuntu:22.04
|
||||
before_script:
|
||||
- apt-get update -y
|
||||
- apt-get install -y curl zip
|
||||
script:
|
||||
- cd build/linux/x64/release/bundle
|
||||
- zip -r ../../../../../${CI_PROJECT_NAME}-linux-${CI_COMMIT_TAG}.zip .
|
||||
- cd ../../../../../
|
||||
- |
|
||||
curl --header "JOB-TOKEN: $CI_JOB_TOKEN" \
|
||||
--upload-file ${CI_PROJECT_NAME}-linux-${CI_COMMIT_TAG}.zip \
|
||||
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${CI_PROJECT_NAME}/${CI_COMMIT_TAG}/${CI_PROJECT_NAME}-linux-${CI_COMMIT_TAG}.zip"
|
||||
dependencies:
|
||||
- build_linux
|
||||
only:
|
||||
- tags
|
||||
when: manual
|
||||
|
||||
# Релиз на GitLab
|
||||
release:
|
||||
stage: deploy
|
||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
||||
script:
|
||||
- |
|
||||
release-cli create \
|
||||
--name "Release $CI_COMMIT_TAG" \
|
||||
--tag-name $CI_COMMIT_TAG \
|
||||
--description "Release $CI_COMMIT_TAG" \
|
||||
--assets-link "{\"name\":\"Android APK\",\"url\":\"${CI_PROJECT_URL}/-/jobs/artifacts/$CI_COMMIT_TAG/download?job=build_android\"}" \
|
||||
--assets-link "{\"name\":\"Linux App\",\"url\":\"${CI_PROJECT_URL}/-/jobs/artifacts/$CI_COMMIT_TAG/download?job=build_linux\"}"
|
||||
dependencies:
|
||||
- build_android
|
||||
- build_linux
|
||||
only:
|
||||
- tags
|
||||
when: manual
|
||||
Reference in New Issue
Block a user