Skip to content

Commit

Permalink
Merge pull request #46 from niscy-eudiw/main
Browse files Browse the repository at this point in the history
Automated Application Versioning via Fastlane
  • Loading branch information
stzouvaras authored Mar 8, 2024
2 parents 8476ab0 + 9196a4f commit af8a808
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 47 deletions.
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ GEM
fastlane-plugin-appcenter (2.1.2)
fastlane-plugin-get_version_name (0.2.2)
fastlane-plugin-increment_version_code (0.4.3)
fastlane-plugin-properties (1.1.2)
java-properties
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.53.0)
google-apis-core (>= 0.11.0, < 2.a)
Expand Down Expand Up @@ -151,6 +153,7 @@ GEM
http-cookie (1.0.5)
domain_name (~> 0.5)
httpclient (2.8.3)
java-properties (0.3.0)
jmespath (1.6.2)
json (2.7.1)
jwt (2.7.1)
Expand Down Expand Up @@ -219,6 +222,7 @@ DEPENDENCIES
fastlane-plugin-appcenter
fastlane-plugin-get_version_name
fastlane-plugin-increment_version_code
fastlane-plugin-properties

BUNDLED WITH
2.4.10
61 changes: 39 additions & 22 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

require "date"

default_platform(:android)

platform :android do
Expand All @@ -21,19 +23,17 @@ platform :android do
lane :deploy do
git_pull

buildVersion = version_name(buildType: ENV["APP_BUILD_TYPE"])
appcenter_build_number = latest_appcenter_release(
appName: ENV["APP_CENTER_APP_NAME"],
appVersion: buildVersion,
appToken: ENV["APP_CENTER_APP_TOKEN"],
ownerName: ENV["APP_CENTER_ACCOUNT"],
)

buildNumber = build_number(versionNumber: appcenter_build_number)

fullVersion = full_version(
buildName: buildVersion,
buildNumber: buildNumber,
)
calver(buildCode: buildNumber)
buildVersion = version_name(buildType: ENV["APP_BUILD_TYPE"])

tagVersion = tag_name(
buildName: buildVersion,
buildNumber: buildNumber,
Expand All @@ -59,6 +59,7 @@ platform :android do

clean_build_artifacts
reset_versioncode
reset_versionname

add_git_tag(
tag: tagVersion,
Expand All @@ -80,7 +81,7 @@ platform :android do
app_name: appName,
file: "app/build/outputs/apk/#{path}/release/app-#{path}-release.apk",
notify_testers: true,
destinations: groups
destinations: groups,
)
end

Expand Down Expand Up @@ -111,15 +112,6 @@ platform :android do
number
end

desc "Build Full version"
lane :full_version do |values|
buildName = values[:buildName]
buildNumber = values[:buildNumber]
version = "[BUILD_VERSION=#{buildName} BUILD_NUMBER=#{buildNumber}]"
puts "Full version: #{version}"
version
end

desc "Build Tag Name"
lane :tag_name do |values|
buildName = values[:buildName]
Expand All @@ -133,12 +125,14 @@ platform :android do

desc "Get version version From Project"
lane :version_name do |values|
buildType = values[:buildType]
versionName = get_version_name(
gradle_file_path: "version.properties",
ext_constant_name: "VERSION_NAME",
).sub("VERSION_NAME=", "")
"#{versionName}-#{buildType}"
buildType = values[:buildType]
versionName = get_properties_value(
key: "VERSION_NAME",
path: "version.properties",
)
version = "#{versionName}-#{buildType}"
puts "Version retrieved from properties: #{version}"
version
end

desc "Set versionCode back to default 1"
Expand All @@ -148,4 +142,27 @@ platform :android do
version_code: 1,
)
end

desc "Set versionName back to default yyyy.d.m"
lane :reset_versionname do
set_properties_value(
path: "version.properties",
key: "VERSION_NAME",
value: "yyyy.d.m",
)
end

desc "Build Version"
lane :calver do |values|
buildCode = values[:buildCode]
date = DateTime.now
version = "#{date.strftime("%Y.%-m")}.#{buildCode}"
puts "Generated Calver: #{version}"
set_properties_value(
path: "version.properties",
key: "VERSION_NAME",
value: version,
)
version
end
end
2 changes: 1 addition & 1 deletion fastlane/Pluginfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# Ensure this file is checked in to source control!

gem 'fastlane-plugin-increment_version_code'
gem 'fastlane-plugin-get_version_name'
gem 'fastlane-plugin-appcenter'
gem 'fastlane-plugin-properties'
24 changes: 16 additions & 8 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ Get Release version From AppCenter

Build Number

### android full_version

```sh
[bundle exec] fastlane android full_version
```

Build Full version

### android tag_name

```sh
Expand All @@ -79,6 +71,22 @@ Get version version From Project

Set versionCode back to default 1

### android reset_versionname

```sh
[bundle exec] fastlane android reset_versionname
```

Set versionName back to default yyyy.d.m

### android calver

```sh
[bundle exec] fastlane android calver
```

Build Version

----

This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
Expand Down
17 changes: 1 addition & 16 deletions version.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
#
# Copyright (c) 2023 European Commission
#
# Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European
# Commission - subsequent versions of the EUPL (the "Licence"); You may not use this work
# except in compliance with the Licence.
#
# You may obtain a copy of the Licence at:
# https://joinup.ec.europa.eu/software/page/eupl
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the Licence for the specific language
# governing permissions and limitations under the Licence.
#
VERSION_NAME=2024.02.1
VERSION_NAME=yyyy.d.m

0 comments on commit af8a808

Please sign in to comment.