Skip to content

Commit 57e7f4e

Browse files
committed
ci: prepare repo for new CI/CD runners architecture
- Add `abbrev` in Gemfile as it made Fastlane failed on new runners - Add missing symbol for outputs - More debug log in Fastfile for GitHub API - Commit hash no more in environment variable Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent 2bb30d3 commit 57e7f4e

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

DesignToolbox/fastlane/Fastfile

+10-14
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ GITHUB_ORG_REPO = "Orange-OpenSource/ouds-ios"
5353
# Fine grained personal access token with enough permissions for the suitable GitHub project
5454
GITHUB_ACCESS_TOKEN = ENV['GITHUB_ACCESS_TOKEN']
5555

56-
# Should be last commit full hash, for builds and tags
57-
IOS_APP_COMMIT_SHA = ENV['IOS_APP_COMMIT_SHA']
58-
5956
# Project configuration
6057
# ---------------------
6158

@@ -223,7 +220,7 @@ platform :ios do
223220
desc "BUILD & UPLOAD TO TESTFLIGHT ALPHA APP"
224221
lane :alpha do |params|
225222
issues_numbers = params[:issueNumber]
226-
puts "👉 Alpha (commit hash = '#{params[:commitHash]}, issue number = '#{issues_numbers}')"
223+
puts "👉 Alpha (commit hash = '#{params[:commitHash]}', issue number = '#{issues_numbers}')"
227224

228225
if issues_numbers.nil? || issues_numbers.empty?
229226
puts "❌ Error: No issues numbers have been given for alpha builds, nothing will be done"
@@ -486,9 +483,8 @@ platform :ios do
486483
publish_mattermost_notification("⚙️ 🤔 No commit hash has been given, no tag can be created")
487484
return false
488485
else
489-
expected_git_tag = "ci/" + commitHash[0,7]
490-
if create_tag(expected_git_tag)
491-
publish_mattermost_notification("📦 ✅ New Git tag created: #{expected_git_tag}")
486+
if create_tag("ci", commitHash)
487+
publish_mattermost_notification("📦 ✅ New Git CI tag created for commit #{commitHash}")
492488
return true
493489
else
494490
return false
@@ -510,9 +506,8 @@ platform :ios do
510506
publish_mattermost_notification("⚙️ 🤔 No commit hash has been given, no tag can be created")
511507
return false
512508
else
513-
expected_git_tag = "Test_Flight/" + commitHash[0,7]
514-
if create_tag(expected_git_tag)
515-
publish_mattermost_notification("📦 ✅ New Git tag created: #{expected_git_tag}")
509+
if create_tag("Test_Flight", commitHash)
510+
publish_mattermost_notification("📦 ✅ New Git Test_Flight tag created for commit #{commitHash}")
516511
return true
517512
else
518513
return false
@@ -526,7 +521,7 @@ platform :ios do
526521

527522
# Creates a Git tag at given commit through HTTP protocol to prevent proxy or firewalls to block SSH requests.
528523
# Not possible also to make repository mirroring because of the current purchased plan of the GitLab instance.
529-
def create_tag(tag)
524+
def create_tag(prefix, commitHash)
530525

531526
# Check personal access token for tag creation
532527
if GITHUB_ACCESS_TOKEN.nil? || GITHUB_ACCESS_TOKEN.empty?
@@ -535,6 +530,7 @@ platform :ios do
535530
return false
536531
else
537532
# Check if given tag exists yet
533+
tag = "#{prefix}/" + commitHash[0,7]
538534
puts "ℹ️ Check if '#{tag}' exists yet"
539535

540536
uri = URI("https://api.github.com/repos/#{GITHUB_ORG_REPO}/tags")
@@ -545,7 +541,7 @@ platform :ios do
545541
puts "ℹ️ The tag '#{tag}' still exists, won't create new tag"
546542
return false
547543
else
548-
puts "ℹ️ Commit SHA to tag is '#{IOS_APP_COMMIT_SHA}'"
544+
puts "ℹ️ Commit SHA to tag is '#{commitHash}'"
549545

550546
uri = URI("https://api.github.com/repos/#{GITHUB_ORG_REPO}/git/refs")
551547
http = Net::HTTP.new(uri.host, uri.port)
@@ -555,15 +551,15 @@ platform :ios do
555551
request['Accept'] = 'application/vnd.github+json'
556552
request['Authorization'] = "Bearer #{GITHUB_ACCESS_TOKEN}"
557553
request['X-GitHub-Api-Version'] = '2022-11-28'
558-
request.body = { ref: "refs/tags/#{tag}", sha: IOS_APP_COMMIT_SHA }.to_json
554+
request.body = { ref: "refs/tags/#{tag}", sha: commitHash }.to_json
559555

560556
response = http.request(request)
561557

562558
if response.code.to_i == 201
563559
puts "ℹ️ Light tag '#{tag}' published in repository"
564560
return true
565561
else
566-
puts "❌ Error: Failed to publish light tag '#{tag}'"
562+
puts "❌ Error: Failed to publish light tag '#{tag}' (#{response.code.to_i})"
567563
return false
568564
end
569565
end

Gemfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
source "https://rubygems.org"
1515

16-
gem 'cocoapods', '1.16.2'
16+
gem 'abbrev', '0.1.2'
17+
gem 'cocoapods', '1.16.2'
1718
gem 'fastlane', '2.227.0'
1819
gem 'fastlane-plugin-changelog', '0.16.0'
1920
gem 'fastlane-plugin-mattermost', '1.3.2'

Gemfile.lock

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ GEM
55
base64
66
nkf
77
rexml
8+
abbrev (0.1.2)
89
activesupport (7.2.2.1)
910
base64
1011
benchmark (>= 0.3)
@@ -322,6 +323,7 @@ PLATFORMS
322323
x86_64-linux-musl
323324

324325
DEPENDENCIES
326+
abbrev (= 0.1.2)
325327
cocoapods (= 1.16.2)
326328
fastlane (= 2.227.0)
327329
fastlane-plugin-changelog (= 0.16.0)

0 commit comments

Comments
 (0)