diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4867b326c7..cf5bf44478 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,9 +10,6 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v2.1.0 - with: - fetch-depth: '0' - ref: 'master' - name: Install Fastlane run: bundle install - name: Deploy new version @@ -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 \ No newline at end of file diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 0a09ccadfb..ce23e0b5f6 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -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 @@ -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}" @@ -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 \ No newline at end of file diff --git a/fastlane/get_previous_tag.sh b/fastlane/get_previous_tag.sh deleted file mode 100755 index 33349f7ccd..0000000000 --- a/fastlane/get_previous_tag.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -all_tags=`git tag -l | wc -l` - -if [ $all_tags = 0 ] || [ $all_tags = 1 ] -then - printf `git rev-list --max-parents=0 HEAD` -else - previous_tag=`git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1)` - printf `git show-ref -s $previous_tag` -fi \ No newline at end of file