From e27e66f22bbb48962fd4e2e83e96c6fd1cbce74c Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Fri, 22 Jul 2022 16:23:50 +0300 Subject: [PATCH] Improve release process - remove towncrier logs from PR builds and move them to github releases - set build version based on current time - bump app version --- .github/workflows/release-alpha.yml | 8 -------- ElementX.xcodeproj/project.pbxproj | 4 ++-- ElementX/SupportingFiles/target.yml | 2 +- fastlane/Fastfile | 30 ++++++++++++++++------------- fastlane/changelog.rb | 19 ++++++++++++++++++ 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release-alpha.yml b/.github/workflows/release-alpha.yml index e92b514d5..0e2a7c0c0 100644 --- a/.github/workflows/release-alpha.yml +++ b/.github/workflows/release-alpha.yml @@ -81,18 +81,10 @@ jobs: DIAWI_API_TOKEN: ${{ secrets.DIAWI_API_TOKEN }} GITHUB_PR_NUMBER: ${{ github.event.number }} - - name: Read version_changes.md - id: read_changes - uses: juliangruber/read-file-action@v1 - with: - path: ./version_changes.md - - name: Add release notes and Diawi info uses: NejcZdovc/comment-pr@v1 with: message: | - ${{ steps.read_changes.outputs.content }} - :iphone: Scan the QR code below to install the build for this PR. :lock: This build is for internal testing purpose. Only devices listed in the ad-hoc provisioning profile can install Element Alpha. diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 67edd7511..46ef00fe2 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -2367,7 +2367,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.1; + MARKETING_VERSION = 1.0.2; PRODUCT_BUNDLE_IDENTIFIER = io.element.elementx; PRODUCT_NAME = ElementX; SDKROOT = iphoneos; @@ -2389,7 +2389,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0.1; + MARKETING_VERSION = 1.0.2; PRODUCT_BUNDLE_IDENTIFIER = io.element.elementx; PRODUCT_NAME = ElementX; SDKROOT = iphoneos; diff --git a/ElementX/SupportingFiles/target.yml b/ElementX/SupportingFiles/target.yml index 0307f6941..b7dc5d3a4 100644 --- a/ElementX/SupportingFiles/target.yml +++ b/ElementX/SupportingFiles/target.yml @@ -51,7 +51,7 @@ targets: base: PRODUCT_NAME: ElementX PRODUCT_BUNDLE_IDENTIFIER: io.element.elementx - MARKETING_VERSION: 1.0.1 + MARKETING_VERSION: 1.0.2 CURRENT_PROJECT_VERSION: 1 DEVELOPMENT_TEAM: 7J4U792NQT CODE_SIGN_ENTITLEMENTS: ElementX/SupportingFiles/ElementX.entitlements diff --git a/fastlane/Fastfile b/fastlane/Fastfile index b700b5e19..ab156dd7d 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -42,8 +42,6 @@ lane :alpha do upload_to_diawi() - export_version_changes(version: version) - end lane :build_and_publish_on_github do @@ -99,13 +97,6 @@ lane :tests do end -private_lane :export_version_changes do |options| - Dir.chdir("..") do - sh("sed -i '.tmp' 's/CHANGES.md/version_changes.md/g' towncrier.toml") - Changelog.update_topmost_section(version: options[:version], additional_entries: {}) - end -end - private_lane :config_xcodegen_alpha do target_file_path = "../ElementX/SupportingFiles/target.yml" data = YAML.load_file target_file_path @@ -151,20 +142,33 @@ private_lane :release_to_github do diawi_app_id = URI(diawi_link).path.split('/').last diawi_qr_code_link = "https://www.diawi.com/qrcode/link/#{diawi_app_id}" - release_version = "#{get_version_number()}-#{Time.now.strftime("%Y%m%d%H%M")}" + # Increment build number to current date + build_number = Time.now.strftime("%Y%m%d%H%M") + increment_build_number(build_number: build_number) + + release_version = get_version_number() + + changes = export_version_changes(version: release_version) github_release = set_github_release( repository_name: "vector-im/element-x-ios", api_token: api_token, name: release_version, tag_name: release_version, - is_generate_release_notes: true, + is_generate_release_notes: false, description: "[iOS AdHoc Release - Diawi Link](#{diawi_link}) - ![QR code](#{diawi_qr_code_link})", - # upload_assets: ["build/ElementX.app.zip"] + ![QR code](#{diawi_qr_code_link}) + #{changes}" ) end +private_lane :export_version_changes do |options| + Dir.chdir("..") do + # Changelog.update_topmost_section(version: options[:version], additional_entries: {}) + Changelog.extract_first_section + end +end + private_lane :update_app_icon do |options| caption_text = options[:caption_text] UI.user_error!("Invalid caption text.") unless !caption_text.to_s.empty? diff --git a/fastlane/changelog.rb b/fastlane/changelog.rb index 404c7131a..93b73bf05 100644 --- a/fastlane/changelog.rb +++ b/fastlane/changelog.rb @@ -11,6 +11,8 @@ require "date" # Helper methods to handle updates of the Changelog file # module Changelog + CHANGES_SEPARATOR_REGEX = /^\#\#\ Changes/.freeze + FILE = "CHANGES.md" # Update the topmost section of the changelog to put version+date in title + add entry for dependency updates # @@ -40,5 +42,22 @@ module Changelog # Let towncrier update the change system("towncrier", "build", "--version", "#{version}", "--yes") end + + # Returns the first section of the Changelog, corresponding to the changes in the latest version + # + def self.extract_first_section + lines = [] + File.open(FILE, "r") do |file| + section_index = 0 + file.each_line do |line| + is_separator_line = (line.chomp =~ CHANGES_SEPARATOR_REGEX) + section_index += 1 if is_separator_line + break if section_index >= 2 + + lines.append(line) if section_index == 1 + end + end + lines[0..-2].join # Remove last line (title of section 2) + end end