Skip to content

Commit 9784bd0

Browse files
lancy-megargmez
authored andcommitted
IOS-9789: Fix the Merge release script issue
1 parent f964034 commit 9784bd0

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

scripts/MergeRelease/Sources/GithubManager.swift

+34-7
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,47 @@ struct GithubManager {
77
githubAccessToken: String,
88
message: String
99
) async throws {
10-
try runInShell("git remote add public https://megaiospush:\(githubAccessToken)@github.com/meganz/iOS.git")
11-
try runInShell("git fetch public")
12-
try runInShell("git fetch origin")
13-
try runInShell("git checkout origin/master")
14-
try runInShell("git pull origin master")
15-
try runInShell("git config http.postBuffer 100000000")
16-
try runInShell("git push public origin/master")
10+
try pushGitlabBranch(withName: "master", toGithubWithToken: githubAccessToken)
11+
1712
try await createReleaseOnGithub(
1813
for: version,
1914
githubBearerToken: githubAccessToken,
2015
message: message
2116
)
2217
}
2318

19+
private static func pushGitlabBranch(
20+
withName branchName: String,
21+
toGithubWithToken githubAccessToken: String
22+
) throws {
23+
// checkout specified branch and pull the latest changes
24+
do {
25+
try runInShell("git checkout \(branchName)")
26+
try runInShell("git pull origin \(branchName)")
27+
} catch {
28+
print("Error checking out and pull from GitLab: \(error)")
29+
throw error
30+
}
31+
32+
// Add the GitHub remote
33+
do {
34+
try runInShell("git remote add public https://megaiospush:\(githubAccessToken)@github.com/meganz/iOS.git")
35+
try runInShell("git fetch public")
36+
} catch {
37+
print("Error adding or fetching from the GitHub remote: \(error)")
38+
throw error
39+
}
40+
41+
// Push the GitLab branch to GitHub
42+
do {
43+
try runInShell("git config http.postBuffer 100000000")
44+
try runInShell("git push public \(branchName)")
45+
} catch {
46+
print("Error pushing to GitHub: \(error)")
47+
throw error
48+
}
49+
}
50+
2451
static func createReleaseOnGithub(
2552
for version: String,
2653
githubBearerToken: String,

0 commit comments

Comments
 (0)