@@ -7,20 +7,47 @@ struct GithubManager {
7
7
githubAccessToken: String ,
8
8
message: String
9
9
) 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
+
17
12
try await createReleaseOnGithub (
18
13
for: version,
19
14
githubBearerToken: githubAccessToken,
20
15
message: message
21
16
)
22
17
}
23
18
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
+
24
51
static func createReleaseOnGithub(
25
52
for version: String ,
26
53
githubBearerToken: String ,
0 commit comments