rubiconba / fastlane-plugin-flutter-version-manager

Fastlane plugin that is used to manage app versioning of Flutter project
MIT License
35 stars 11 forks source link

Can't find new version on main branch gitlab repo #10

Closed talbiislam96 closed 2 years ago

talbiislam96 commented 2 years ago

The plugin works just fine remotely , I also managed to make it work on GitLab CI , the problem is that on my pipeline everything is going well , I can see the new version + I added a lane that sends me a message on slack with the new version etc But when I checked my main branch I did not find the modifications on the version .yml file neither pubspec this is my fastfile :

default_platform(:android)

def versionString()
  file=YAML.load_file("../../version.yml")
  version="#{file['major']}.#{file['minor']}.#{file['patch']}"
  UI.message version
  return version
end

def send_app_version(exception)
  ver = versionString
  slack(
      message: "App new version after last merge is ",
      success: false,
      slack_url: "https://your slack incoming webhook url",
      attachment_properties: {
          fields: [
              {
                  title: "Build number",
                  value: ENV["BUILD_NUMBER"],
              },
              {
                  title: "Error message",
                  value: exception.to_s,
                  short: false
              }
          ]
      }
  )
end

platform :android do
  desc "Runs all the tests"
  lane :test do
    gradle(task: "test")
  end

  desc "Submit a new Beta Build to Crashlytics Beta"
  lane :beta do
    gradle(task: "clean assembleRelease")
    crashlytics

    # sh "your_script.sh"
    # You can also use other beta testing services here
  end

  desc "Deploy a new version to the Google Play"
  lane :deploy do
    gradle(task: "clean assembleRelease")
    upload_to_play_store
  end
end

lane :bump do
  flutter_version_manager(
    arguments: "-minor",
    yml: "../version.yml",
    pubspec: "../pubspec.yaml",
    git_repo: ".."

    )

end

platform :android do
  desc "send app version to slack"
  lane :slack_message do
    ver = versionString
      slack(
          message: "App version after last merge is #{ver} ",
          success: true,
          slack_url: "https://hooks.slack.com/services/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"
      )
  end
end

GitLab CI file :


image: "cirrusci/flutter:2.8.1"
before_script:
  - flutter pub get
  - "export VERSION_SHA=`echo ${CI_COMMIT_SHORT_SHA}` && echo $VERSION_SHA"
variables:
  ANDROID_COMPILE_SDK: "28"
  ANDROID_BUILD_TOOLS: "28.0.3"
  ANDROID_SDK_TOOLS:   "4333796"
  VERSION_SHA: $CI_COMMIT_SHORT_SHA

stages:
  - test # All jobs related for testing such as Unit Test
  - build
  - versionning

flutter_test: # Name of the lane
  stage: test # type of stage
  script:
    - flutter test # Run Flutter test
flutter_build_android: #Job name
  stage: build # kind of job
  variables:
    VERSION_SHA: $CI_COMMIT_SHORT_SHA
  before_script:
    - flutter packages get
    - flutter clean
  script:
    - flutter build apk
  artifacts:
    paths:
      - build/app/outputs/apk/release/app-release.apk

flutter_increment_app_version: 
  dependencies: []
  stage: versionning 
  before_script:
    - cd android/
    - gem update --system
    - export BUNDLE_GEMFILE=$(pwd)/Gemfile
    - bundle install
    - fastlane install_plugins --verbose
  script:

    - bundle exec fastlane bump
    - bundle exec fastlane slack_message
  only:
    - merge_requests

pipeline :


+-----------------------------------------+---------+-------------------------+
[410](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L410)|                                Used plugins                                 |
[411](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L411)+-----------------------------------------+---------+-------------------------+
[412](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L412)| Plugin                                  | Version | Action                  |
[413](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L413)+-----------------------------------------+---------+-------------------------+
[414](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L414)| fastlane-plugin-flutter_version_manager | 1.0.0   | flutter_version_manager |
[415](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L415)+-----------------------------------------+---------+-------------------------+
[416](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L416)[17:00:57]: ------------------------------
[417](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L417)[17:00:57]: --- Step: default_platform ---
[418](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L418)[17:00:57]: ------------------------------
[419](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L419)[17:00:57]: Driving the lane 'bump' πŸš€
[420](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L420)[17:00:57]: -------------------------------------
[421](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L421)[17:00:57]: --- Step: flutter_version_manager ---
[422](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L422)[17:00:57]: -------------------------------------
[423](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L423)[17:00:57]: Previous app version: 1.0.0+2
[424](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L424)[17:00:57]: New app version: 1.1.0+51246021
[425](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L425)+------+-------------------------+-------------+
[426](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L426)|               fastlane summary               |
[427](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L427)+------+-------------------------+-------------+
[428](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L428)| Step | Action                  | Time (in s) |
[429](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L429)+------+-------------------------+-------------+
[430](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L430)| 1    | default_platform        | 0           |
[431](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L431)| 2    | flutter_version_manager | 0           |
[432](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L432)+------+-------------------------+-------------+
[433](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L433)[17:00:57]: fastlane.tools finished successfully πŸŽ‰
[434](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L434)$ bundle exec fastlane slack_message
[435](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L435)Your Gemfile lists the gem fastlane-plugin-flutter_version_manager (>= 0) more than once.
[436](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L436)You should probably keep only one of them.
[437](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L437)Remove any duplicate entries and specify the gem only once.
[438](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L438)While it's not a problem now, it could cause errors if you change the version of one of them later.
[439](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L439)Your Gemfile lists the gem git (>= 0) more than once.
[440](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L440)You should probably keep only one of them.
[441](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L441)Remove any duplicate entries and specify the gem only once.
[442](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L442)While it's not a problem now, it could cause errors if you change the version of one of them later.
[443](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L443)[17:00:59]: Plugin 'FlutterVersionManager' overwrites already loaded action 'flutter_version_manager'
[444](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L444)+-----------------------------------------+---------+-------------------------+
[445](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L445)|                                Used plugins                                 |
[446](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L446)+-----------------------------------------+---------+-------------------------+
[447](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L447)| Plugin                                  | Version | Action                  |
[448](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L448)+-----------------------------------------+---------+-------------------------+
[449](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L449)| fastlane-plugin-flutter_version_manager | 1.0.0   | flutter_version_manager |
[450](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L450)+-----------------------------------------+---------+-------------------------+
[451](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L451)[17:00:59]: ------------------------------
[452](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L452)[17:00:59]: --- Step: default_platform ---
[453](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L453)[17:00:59]: ------------------------------
[454](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L454)[17:00:59]: Driving the lane 'android slack_message' πŸš€
[455](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L455)[17:00:59]: 1.1.0
[456](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L456)[17:00:59]: -------------------
[457](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L457)[17:00:59]: --- Step: slack ---
[458](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L458)[17:00:59]: -------------------
[459](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L459)[17:00:59]: Successfully sent Slack notification
[460](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L460)+------+------------------+-------------+
[461](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L461)|           fastlane summary            |
[462](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L462)+------+------------------+-------------+
[463](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L463)| Step | Action           | Time (in s) |
[464](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L464)+------+------------------+-------------+
[465](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L465)| 1    | default_platform | 0           |
[466](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L466)| 2    | slack            | 0           |
[467](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L467)+------+------------------+-------------+
[468](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L468)[17:00:59]: fastlane.tools finished successfully πŸŽ‰

[470](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L470)
Cleaning up project directory and file based variables
00:01
[472](https://gitlab.com/wecraft.tn/projects/xenon/front/app-mobile/-/jobs/2332607341#L472)Job succeeded

I've got a function that reads the version from version.yml file returns it so I can use it to send slack messages with the app version like so :

def versionString()
  file=YAML.load_file("../../version.yml")
  version="#{file['major']}.#{file['minor']}.#{file['patch']}"
  UI.message version
  return version
end

and as you can see in the pipeline , it successfully read the version from the file and sent it in a slack message . How can this happen when the version.yml file has not been changed when I checked on my main repo? where are the changes gone ? and why are the version.yml and pubspec.yaml files unchanged on main branch when clearly the version changed? How can I fix this please I need to see the changes on my main branch after the pipeline is successfully run. Thank you in advance

talbiislam96 commented 2 years ago

@davormaricdev can you please answer me ?

davormaricdev commented 2 years ago

Hi @talbiislam96 The changes aren't there because the changes were not committed to git branch.

Git Commit

talbiislam96 commented 2 years ago

I apply git commit on main in the ci ?

davormaricdev commented 2 years ago

If that works for you, then yes. Closing this topic as it is no longer relevant to this plugin.