Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
ci: changed release workflow to support hofixes (#661)
Browse files Browse the repository at this point in the history
* changed release workflow to support hofixes

* removed discord message script

* fixed change log

Signed-off-by: Victor Rabelo <[email protected]>

* removed discord env variable

* added fetch

* removed test code

* fixed fastfile references

Signed-off-by: Victor Rabelo <[email protected]>

* added release lanes

Signed-off-by: Victor Rabelo <[email protected]>

* removed unused file and added checkout to master when is not a hot fix

Signed-off-by: Victor Rabelo <[email protected]>

* added 'release' to the branch name

Signed-off-by: Victor Rabelo <[email protected]>

* changed the repository from fixed string to variable

Signed-off-by: Victor Rabelo <[email protected]>
  • Loading branch information
victorrabelozup authored Aug 7, 2020
1 parent 72b8337 commit 141e04e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 29 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: '0'
ref: 'master'
- name: Install Fastlane
run: bundle install
- name: Deploy new version
Expand All @@ -24,7 +21,8 @@ jobs:
NX_REPO_URL: ${{ secrets.NX_REPO_URL }}
GITHUB_USER: ${{ secrets.NAME_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
TAG_NAME: ${{ github.REF }}
REPO: ${{ github.repository }}
run: bundle exec fastlane deploy

74 changes: 60 additions & 14 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,42 @@ end

desc "Publish new release based on last two tags"
lane :deploy do
git_pull
ENV["VERSION_DEPLOY"] = last_git_tag

sh "fastlane android deploy_to_production"
sh "fastlane backend deploy_to_production"

sh "fastlane ios release"
sh "git fetch"
pattern = "*[0-9]"
tagName = "master"
if ENV["TAG_NAME"].index("-") # Hotfix
tagName = "release/" + ENV["TAG_NAME"].split("/").last
platformHotfix = tagName.split("-").last
pattern = "*-#{platformHotfix}"
end
sh "git checkout #{tagName}"

ENV["VERSION_DEPLOY"] = last_git_tag(pattern: pattern)
if platformHotfix == "iOS"
puts "iOS Hotfix release"
sh "fastlane ios release"
elsif platformHotfix == "android"
puts "Android Hotfix release"
sh "fastlane android deploy_to_production"
elsif platformHotfix == "backend"
puts "Backend Hotfix release"
sh "fastlane backend deploy_to_production"
else
puts "Normal Release"
sh "fastlane android deploy_to_production"
sh "fastlane backend deploy_to_production"
sh "fastlane ios release"
end

releaseNotes = release_notes
sh "bash ./delete_release.sh"
set_github_release(
repository_name: "ZupIT/beagle",
repository_name: ENV["REPO"],,
api_token: ENV["REPO_TOKEN"],
name: ENV["VERSION_DEPLOY"],
tag_name: ENV["VERSION_DEPLOY"],
description: release_notes,
commitish: "master"
description: releaseNotes,
commitish: tagName
)
end

Expand Down Expand Up @@ -189,15 +209,17 @@ platform :backend do

end


desc "Generate release notes"
private_lane :release_notes do
get_previous_tag = sh "bash ./get_previous_tag.sh"
get_previous_tag = lastExpectedVersion(newVersion:ENV["VERSION_DEPLOY"])
tagHashes = sh "git show-ref -s #{get_previous_tag}"

lane_context[SharedValues::RELEASE_ANALYZED] = true
lane_context[SharedValues::RELEASE_LAST_TAG_HASH] = get_previous_tag
lane_context[SharedValues::RELEASE_NEXT_VERSION] = ENV["VERSION_DEPLOY"]
lane_context[SharedValues::RELEASE_LAST_TAG_HASH] = tagHashes.split("\n").last
lane_context[SharedValues::RELEASE_NEXT_VERSION] = ENV["TAG_NAME"]
lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN] = "(feat|fix|refactor|perf|chore|test|docs|no_type)(:)()(.*)"
changelog = conventional_changelog(display_title: false, display_links: false)
changelog = changelog.gsub("**::** ", "")
"\nRelease notes #{ ENV["VERSION_DEPLOY"] }
\nChanges:
\n#{changelog}"
Expand Down Expand Up @@ -231,3 +253,27 @@ error do |lane, exception, options|
end
end
end

lane :lastExpectedVersion do |params|
platform = params[:newVersion].split("-")
releaseNumberArray = platform.first.split(".")
lastVersion = ""
calculated = false
for number in releaseNumberArray.reverse()
intNumber = number.to_i
if intNumber != 0 && !calculated
intNumber -= 1
calculated = true
end
lastVersion = ".#{intNumber}" + lastVersion
end
lastVersion[0] = ""

version = ""
if platform.length > 1
version = "#{lastVersion}-#{platform[1]}"
else
version = lastVersion
end
"#{version}"
end
11 changes: 0 additions & 11 deletions fastlane/get_previous_tag.sh

This file was deleted.

0 comments on commit 141e04e

Please sign in to comment.