Skip to content

Commit

Permalink
fixed version names
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehan27 committed Aug 6, 2024
1 parent 1bc199a commit 0c46882
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
15 changes: 2 additions & 13 deletions .github/workflows/build-sample-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,23 @@ jobs:
working-directory: "apps/${{ matrix.sample-app }}"

- name: Generate New Version
id: generate_version
uses: maierj/fastlane-action@v3.1.0
with:
working-directory: "apps/${{ matrix.sample-app }}"
lane: "generate_new_version"
options: |
branch_name=${{ github.ref_name }}
pull_request_number=${{ github.event.pull_request.number }}
env:
NEW_VERSION_NAME: ${{ steps.generate_version.outputs.NEW_VERSION_NAME }}
NEW_VERSION_CODE: ${{ steps.generate_version.outputs.NEW_VERSION_CODE }}
options: '{"branch_name":"${{ github.ref_name }}", "pull_request_number":"${{ github.event.pull_request.number }}"}'

# - name: Update Flutter SDK Version
# uses: maierj/fastlane-action@v3.1.0
# with:
# lane: "update_flutter_sdk_version"
# subdirectory: "apps/${{ matrix.sample-app }}"
# options: |
# version_name=${{ steps.generate_version.outputs.NEW_VERSION_NAME }}
# version_code=${{ steps.generate_version.outputs.NEW_VERSION_CODE }}
#
- name: Update Sample App Version
uses: maierj/fastlane-action@v3.1.0
with:
lane: "update_flutter_app_version"
subdirectory: "apps/${{ matrix.sample-app }}"
options: |
version_name=${{ steps.generate_version.outputs.NEW_VERSION_NAME }}
version_code=${{ steps.generate_version.outputs.NEW_VERSION_CODE }}

- name: Install flutter dependencies
run: flutter pub get
Expand Down
15 changes: 8 additions & 7 deletions apps/amiapp_flutter/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ lane :generate_new_version do |options|
commits_count = `git rev-list --count HEAD`.strip
time_in_millis = (Time.now.to_f * 1000).to_i

sdk_version_name = "#{branch_name}.#{commits_count}.0"
if pull_request_number
new_version_name = "#{pull_request_number}.#{commits_count}.0"
else
new_version_name = "#{branch_name}.#{commits_count}.0"
new_version_name = sdk_version_name
end
new_version_code = time_in_millis

ENV['NEW_VERSION_NAME'] = new_version_name
ENV['NEW_VERSION_CODE'] = new_version_code.to_s
ENV['SDK_VERSION_NAME'] = sdk_version_name
ENV['APP_VERSION_NAME'] = new_version_name
ENV['APP_VERSION_CODE'] = new_version_code.to_s

UI.message("Generated new version name: #{new_version_name} and version code: #{new_version_code}")
end
Expand Down Expand Up @@ -75,17 +77,16 @@ end
# Lane to update Flutter app version
lane :update_flutter_sdk_version do |options|
project_path = options[:project_path] || File.join(Dir.pwd, '../../..')
version_name = options[:version_name]
version_code = options[:version_code]
version_name = ENV['SDK_VERSION_NAME']

update_pubspec_version(project_path, version_name)
end

# Lane to update Flutter app version
lane :update_flutter_app_version do |options|
project_path = options[:project_path] || File.join(Dir.pwd, '..')
version_name = options[:version_name]
version_code = options[:version_code]
version_name = ENV['APP_VERSION_NAME']
version_code = ENV['APP_VERSION_CODE']

# To match version format with flutter apps e.g. 1.0.0+1
new_version = "#{version_name}+#{version_code}"
Expand Down

0 comments on commit 0c46882

Please sign in to comment.