@@ -53,9 +53,6 @@ GITHUB_ORG_REPO = "Orange-OpenSource/ouds-ios"
53
53
# Fine grained personal access token with enough permissions for the suitable GitHub project
54
54
GITHUB_ACCESS_TOKEN = ENV [ 'GITHUB_ACCESS_TOKEN' ]
55
55
56
- # Should be last commit full hash, for builds and tags
57
- IOS_APP_COMMIT_SHA = ENV [ 'IOS_APP_COMMIT_SHA' ]
58
-
59
56
# Project configuration
60
57
# ---------------------
61
58
@@ -223,7 +220,7 @@ platform :ios do
223
220
desc "BUILD & UPLOAD TO TESTFLIGHT ALPHA APP"
224
221
lane :alpha do |params |
225
222
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 } ')"
227
224
228
225
if issues_numbers . nil? || issues_numbers . empty?
229
226
puts "❌ Error: No issues numbers have been given for alpha builds, nothing will be done"
@@ -486,8 +483,7 @@ platform :ios do
486
483
publish_mattermost_notification ( "⚙️ 🤔 No commit hash has been given, no tag can be created" )
487
484
return false
488
485
else
489
- expected_git_tag = "ci/" + commitHash [ 0 , 7 ]
490
- if create_tag ( expected_git_tag )
486
+ if create_tag ( "ci" , commitHash )
491
487
publish_mattermost_notification ( "📦 ✅ New Git tag created: #{ expected_git_tag } " )
492
488
return true
493
489
else
@@ -510,8 +506,7 @@ platform :ios do
510
506
publish_mattermost_notification ( "⚙️ 🤔 No commit hash has been given, no tag can be created" )
511
507
return false
512
508
else
513
- expected_git_tag = "Test_Flight/" + commitHash [ 0 , 7 ]
514
- if create_tag ( expected_git_tag )
509
+ if create_tag ( "Test_Flight" , commitHash )
515
510
publish_mattermost_notification ( "📦 ✅ New Git tag created: #{ expected_git_tag } " )
516
511
return true
517
512
else
@@ -526,7 +521,7 @@ platform :ios do
526
521
527
522
# Creates a Git tag at given commit through HTTP protocol to prevent proxy or firewalls to block SSH requests.
528
523
# 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 )
530
525
531
526
# Check personal access token for tag creation
532
527
if GITHUB_ACCESS_TOKEN . nil? || GITHUB_ACCESS_TOKEN . empty?
@@ -535,6 +530,7 @@ platform :ios do
535
530
return false
536
531
else
537
532
# Check if given tag exists yet
533
+ tag = "#{ prefix } /" + commitHash [ 0 , 7 ]
538
534
puts "ℹ️ Check if '#{ tag } ' exists yet"
539
535
540
536
uri = URI ( "https://api.github.com/repos/#{ GITHUB_ORG_REPO } /tags" )
@@ -545,7 +541,7 @@ platform :ios do
545
541
puts "ℹ️ The tag '#{ tag } ' still exists, won't create new tag"
546
542
return false
547
543
else
548
- puts "ℹ️ Commit SHA to tag is '#{ IOS_APP_COMMIT_SHA } '"
544
+ puts "ℹ️ Commit SHA to tag is '#{ commitHash } '"
549
545
550
546
uri = URI ( "https://api.github.com/repos/#{ GITHUB_ORG_REPO } /git/refs" )
551
547
http = Net ::HTTP . new ( uri . host , uri . port )
@@ -555,15 +551,15 @@ platform :ios do
555
551
request [ 'Accept' ] = 'application/vnd.github+json'
556
552
request [ 'Authorization' ] = "Bearer #{ GITHUB_ACCESS_TOKEN } "
557
553
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
559
555
560
556
response = http . request ( request )
561
557
562
558
if response . code . to_i == 201
563
559
puts "ℹ️ Light tag '#{ tag } ' published in repository"
564
560
return true
565
561
else
566
- puts "❌ Error: Failed to publish light tag '#{ tag } '"
562
+ puts "❌ Error: Failed to publish light tag '#{ tag } ' ( #{ response . code . to_i } ) "
567
563
return false
568
564
end
569
565
end
0 commit comments