@@ -29,7 +29,8 @@ Available commands are:
29
29
importkeys -- imports signing keys from env
30
30
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
31
31
nsis -- creates a Windows NSIS installer
32
- aar [ -sign key-id ] [ -upload dest ] -- creates an android archive
32
+ aar [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an Android archive
33
+ xcode [ -sign key-id ] [-deploy repo] [ -upload dest ] -- creates an iOS XCode framework
33
34
xgo [ options ] -- cross builds according to options
34
35
35
36
For all commands, -n prevents execution of external programs (dry run mode).
@@ -130,6 +131,8 @@ func main() {
130
131
doWindowsInstaller (os .Args [2 :])
131
132
case "aar" :
132
133
doAndroidArchive (os .Args [2 :])
134
+ case "xcode" :
135
+ doXCodeFramework (os .Args [2 :])
133
136
case "xgo" :
134
137
doXgo (os .Args [2 :])
135
138
default :
@@ -339,14 +342,21 @@ func archiveBasename(arch string, env build.Environment) string {
339
342
if arch == "android" {
340
343
platform = "android-all"
341
344
}
342
- archive := platform + "-" + build .VERSION ()
345
+ if arch == "ios" {
346
+ platform = "ios-all"
347
+ }
348
+ return platform + "-" + archiveVersion (env )
349
+ }
350
+
351
+ func archiveVersion (env build.Environment ) string {
352
+ version := build .VERSION ()
343
353
if isUnstableBuild (env ) {
344
- archive += "-unstable"
354
+ version += "-unstable"
345
355
}
346
356
if env .Commit != "" {
347
- archive += "-" + env .Commit [:8 ]
357
+ version += "-" + env .Commit [:8 ]
348
358
}
349
- return archive
359
+ return version
350
360
}
351
361
352
362
func archiveUpload (archive string , blobstore string , signer string ) error {
@@ -638,14 +648,15 @@ func doWindowsInstaller(cmdline []string) {
638
648
if err := archiveUpload (installer , * upload , * signer ); err != nil {
639
649
log .Fatal (err )
640
650
}
651
+ }
641
652
642
653
// Android archives
643
654
644
655
func doAndroidArchive (cmdline []string ) {
645
656
var (
646
657
signer = flag .String ("signer" , "" , `Environment variable holding the signing key (e.g. ANDROID_SIGNING_KEY)` )
647
- deploy = flag .String ("deploy" , "" , `Where to upload the deploy the archive (usually "https://oss.sonatype.org")` )
648
- upload = flag .String ("upload" , "" , `Destination to upload the archives (usually "gethstore/builds")` )
658
+ deploy = flag .String ("deploy" , "" , `Destination to deploy the archive (usually "https://oss.sonatype.org")` )
659
+ upload = flag .String ("upload" , "" , `Destination to upload the archive (usually "gethstore/builds")` )
649
660
)
650
661
flag .CommandLine .Parse (cmdline )
651
662
env := build .Env ()
@@ -656,13 +667,13 @@ func doAndroidArchive(cmdline []string) {
656
667
build .MustRun (gomobileTool ("bind" , "--target" , "android" , "--javapkg" , "org.ethereum" , "-v" , "github.com/ethereum/go-ethereum/mobile" ))
657
668
658
669
meta := newMavenMetadata (env )
659
- build .Render ("build/mvn.pom" , meta .PackageString () + ".pom" , 0755 , meta )
670
+ build .Render ("build/mvn.pom" , meta .Package + ".pom" , 0755 , meta )
660
671
661
672
// Skip Maven deploy and Azure upload for PR builds
662
673
maybeSkipArchive (env )
663
674
664
675
// Sign and upload all the artifacts to Maven Central
665
- os .Rename ("geth.aar" , meta .PackageString () + ".aar" )
676
+ os .Rename ("geth.aar" , meta .Package + ".aar" )
666
677
if * signer != "" && * deploy != "" {
667
678
// Import the signing key into the local GPG instance
668
679
if b64key := os .Getenv (* signer ); b64key != "" {
@@ -676,16 +687,16 @@ func doAndroidArchive(cmdline []string) {
676
687
}
677
688
// Upload the artifacts to Sonatype and/or Maven Central
678
689
repo := * deploy + "/service/local/staging/deploy/maven2"
679
- if meta .Unstable {
690
+ if meta .Develop {
680
691
repo = * deploy + "/content/repositories/snapshots"
681
692
}
682
693
build .MustRunCommand ("mvn" , "gpg:sign-and-deploy-file" ,
683
694
"-settings=build/mvn.settings" , "-Durl=" + repo , "-DrepositoryId=ossrh" ,
684
- "-DpomFile=" + meta .PackageString () + ".pom" , "-Dfile=" + meta .PackageString () + ".aar" )
695
+ "-DpomFile=" + meta .Package + ".pom" , "-Dfile=" + meta .Package + ".aar" )
685
696
}
686
697
// Sign and upload the archive to Azure
687
698
archive := "geth-" + archiveBasename ("android" , env ) + ".aar"
688
- os .Rename (meta .PackageString () + ".aar" , archive )
699
+ os .Rename (meta .Package + ".aar" , archive )
689
700
690
701
if err := archiveUpload (archive , * upload , * signer ); err != nil {
691
702
log .Fatal (err )
@@ -708,9 +719,9 @@ func gomobileTool(subcmd string, args ...string) *exec.Cmd {
708
719
}
709
720
710
721
type mavenMetadata struct {
711
- Env build.Environment
712
722
Version string
713
- Unstable bool
723
+ Package string
724
+ Develop bool
714
725
Contributors []mavenContributor
715
726
}
716
727
@@ -740,23 +751,101 @@ func newMavenMetadata(env build.Environment) mavenMetadata {
740
751
}
741
752
}
742
753
}
754
+ // Render the version and package strings
755
+ version := build .VERSION ()
756
+ if isUnstableBuild (env ) {
757
+ version += "-SNAPSHOT"
758
+ }
743
759
return mavenMetadata {
744
- Env : env ,
745
- Version : build . VERSION () ,
746
- Unstable : isUnstableBuild (env ),
760
+ Version : version ,
761
+ Package : "geth-" + version ,
762
+ Develop : isUnstableBuild (env ),
747
763
Contributors : contribs ,
748
764
}
749
765
}
750
766
751
- func (meta mavenMetadata ) VersionString () string {
752
- if meta.Unstable {
753
- return meta .Version + "-SNAPSHOT"
767
+ // XCode frameworks
768
+
769
+ func doXCodeFramework (cmdline []string ) {
770
+ var (
771
+ signer = flag .String ("signer" , "" , `Environment variable holding the signing key (e.g. IOS_SIGNING_KEY)` )
772
+ deploy = flag .String ("deploy" , "" , `Destination to deploy the archive (usually "trunk")` )
773
+ upload = flag .String ("upload" , "" , `Destination to upload the archives (usually "gethstore/builds")` )
774
+ )
775
+ flag .CommandLine .Parse (cmdline )
776
+ env := build .Env ()
777
+
778
+ // Build the iOS XCode framework
779
+ build .MustRun (goTool ("get" , "golang.org/x/mobile/cmd/gomobile" ))
780
+ build .MustRun (gomobileTool ("init" ))
781
+
782
+ archive := "geth-" + archiveBasename ("ios" , env )
783
+ if err := os .Mkdir (archive , os .ModePerm ); err != nil {
784
+ log .Fatal (err )
754
785
}
755
- return meta .Version
786
+ bind := gomobileTool ("bind" , "--target" , "ios" , "--tags" , "ios" , "--prefix" , "GE" , "-v" , "github.com/ethereum/go-ethereum/mobile" )
787
+ bind .Dir , _ = filepath .Abs (archive )
788
+ build .MustRun (bind )
789
+ build .MustRunCommand ("tar" , "-zcvf" , archive + ".tar.gz" , archive )
790
+
791
+ // Skip CocoaPods deploy and Azure upload for PR builds
792
+ maybeSkipArchive (env )
793
+
794
+ // Sign and upload the framework to Azure
795
+ if err := archiveUpload (archive + ".tar.gz" , * upload , * signer ); err != nil {
796
+ log .Fatal (err )
797
+ }
798
+ // Prepare and upload a PodSpec to CocoaPods
799
+ if * deploy != "" {
800
+ meta := newPodMetadata (env )
801
+ build .Render ("build/pod.podspec" , meta .Name + ".podspec" , 0755 , meta )
802
+ build .MustRunCommand ("pod" , * deploy , "push" , meta .Name + ".podspec" )
803
+ }
804
+ }
805
+
806
+ type podMetadata struct {
807
+ Name string
808
+ Version string
809
+ Commit string
810
+ Contributors []podContributor
756
811
}
757
812
758
- func (meta mavenMetadata ) PackageString () string {
759
- return "geth-" + meta .VersionString ()
813
+ type podContributor struct {
814
+ Name string
815
+ Email string
816
+ }
817
+
818
+ func newPodMetadata (env build.Environment ) podMetadata {
819
+ // Collect the list of authors from the repo root
820
+ contribs := []podContributor {}
821
+ if authors , err := os .Open ("AUTHORS" ); err == nil {
822
+ defer authors .Close ()
823
+
824
+ scanner := bufio .NewScanner (authors )
825
+ for scanner .Scan () {
826
+ // Skip any whitespace from the authors list
827
+ line := strings .TrimSpace (scanner .Text ())
828
+ if line == "" || line [0 ] == '#' {
829
+ continue
830
+ }
831
+ // Split the author and insert as a contributor
832
+ re := regexp .MustCompile ("([^<]+) <(.+>)" )
833
+ parts := re .FindStringSubmatch (line )
834
+ if len (parts ) == 3 {
835
+ contribs = append (contribs , podContributor {Name : parts [1 ], Email : parts [2 ]})
836
+ }
837
+ }
838
+ }
839
+ name := "Geth"
840
+ if isUnstableBuild (env ) {
841
+ name += "Develop"
842
+ }
843
+ return podMetadata {
844
+ Name : name ,
845
+ Version : archiveVersion (env ),
846
+ Commit : env .Commit ,
847
+ Contributors : contribs ,
848
+ }
760
849
}
761
850
762
851
// Cross compilation
0 commit comments