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

Return version not only printing it #4

Open krjw-eyev opened 3 years ago

krjw-eyev commented 3 years ago

This is more of a feature request if I am not wrong.

I may misuse this since I am new to fastlane and ruby, but I think it would be great to get the version back when using

version=flutter_version_manager(
        arguments: "-version",
        yml: "./version.yml",
        pubspec: "./pubspec.yaml")

# use version
davormaricdev commented 3 years ago

Agree. Coming up in next release

Morteza-Rastgoo commented 3 years ago

I also needed this to get this to use in a commit message like this:

git commit -m "Version $major.$minor.$patch+$code"

I can still wait for the new release but: Do you think there is a better way of doing it?

Y0ngg4n commented 3 years ago

Would great if this feature comes fast :)

DanOxlade commented 2 years ago

This feature would be really useful, any news on when it will be available?

talbiislam96 commented 2 years ago

@krjw-eyev does the code you posted work ? have you succeeded to get the current version and put it in a variable? I need to know , because am trying to put the version in a git tag but don't know how , since am new to Fastlane and ruby. If anyone can help I'd be grateful.

talbiislam96 commented 2 years ago

@davormaricdev any progress / news on the feature? Is there a way I can read the. version after incrementing it then print it in a git tag ? I'd be grateful for your help

krjw-eyev commented 2 years ago

This is what I am using. I hope it helps you.

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

Usage:

lane :set_version_ios do
    version = versionString()
    increment_version_number_in_xcodeproj(
        version_number: version,   
        xcodeproj: './ios/Runner.xcodeproj'  
    )
end
talbiislam96 commented 2 years ago

@krjw-eyev thank you so much that was extremely helpful. Happy coding

talbiislam96 commented 2 years ago

@krjw-eyev am getting the following error

` No such file or directory @ rb_sysopen - ../version.yml

` apparently it is not able to read version.yml although am sure the path is correct because it can read it in bump version lanes , do you happen to know how I can fix this please?

krjw-eyev commented 2 years ago

It depends where your version.yml file is located. ./ is the current directory ../ is the parent directory. ../../ is the parents parent directory and so on.

My folder structure looks like this:

my-flutter-app/
├─ fastlane/
│  ├─ Fastfile
├─ version.yml

I execute fastlane in the my-flutter-app folder.

talbiislam96 commented 2 years ago

@krjw-eyev thank you for your help , I was using the wrong path. works now :)

Hritik602 commented 1 year ago

Is this plugin discontinued???

Fastlane-plugin-flutter_vers | 1.0.0 | No actions found | | ion_manager

[!] No actions were found while loading one or more plugins Please use bundle exec fastlane with plugins More info - https://docs.fastlane.tools/plugins/using-plugins/#run-with-plugins .

Phando commented 1 year ago

Add these with the appropriate paths to your Fastfile and you should be good to go. They came from a little deeper in the plugin (not my code).

` def versionCode() @git = Git.open('../../') head = @git.object('HEAD') commit = @git.gcommit(head.sha) commit.date.to_i - GIT_OFFSET end

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