github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/ci/release/android_sdk.go (about)

     1  /*
     2   * Copyright (C) 2019 The "MysteriumNetwork/node" Authors.
     3   *
     4   * This program is free software: you can redistribute it and/or modify
     5   * it under the terms of the GNU General Public License as published by
     6   * the Free Software Foundation, either version 3 of the License, or
     7   * (at your option) any later version.
     8   *
     9   * This program is distributed in the hope that it will be useful,
    10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12   * GNU General Public License for more details.
    13   *
    14   * You should have received a copy of the GNU General Public License
    15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16   */
    17  
    18  package release
    19  
    20  import (
    21  	"fmt"
    22  
    23  	"github.com/magefile/mage/sh"
    24  	"github.com/mysteriumnetwork/go-ci/env"
    25  	"github.com/mysteriumnetwork/go-ci/job"
    26  	"github.com/mysteriumnetwork/node/ci/storage"
    27  	"github.com/mysteriumnetwork/node/logconfig"
    28  )
    29  
    30  const (
    31  	// MAVEN_USER user part of token for Sonatype.
    32  	MAVEN_USER = env.BuildVar("MAVEN_USER")
    33  	// MAVEN_PASS password part of token for Sonatype.
    34  	MAVEN_PASS = env.BuildVar("MAVEN_PASS")
    35  
    36  	// REPOSITORY_ID references reposity ID in mvn.settings.
    37  	REPOSITORY_ID = "ossrh"
    38  	// REPOSITORY_URL URL for uploading the artifacts.
    39  	REPOSITORY_URL = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
    40  )
    41  
    42  // ReleaseAndroidSDK releases tag Android SDK to maven repo.
    43  func ReleaseAndroidSDK() error {
    44  	logconfig.Bootstrap()
    45  
    46  	if err := env.EnsureEnvVars(env.TagBuild, env.BuildVersion); err != nil {
    47  		return err
    48  	}
    49  	job.Precondition(func() bool {
    50  		return env.Bool(env.TagBuild)
    51  	})
    52  
    53  	if err := storage.DownloadArtifacts(); err != nil {
    54  		return err
    55  	}
    56  
    57  	artifactBaseName := fmt.Sprintf("build/package/mobile-node-%s", env.Str(env.BuildVersion))
    58  
    59  	// Deploy AAR (android archive)
    60  	if err := sh.RunWithV(map[string]string{
    61  		"MAVEN_USER": env.Str(MAVEN_USER),
    62  		"MAVEN_PASS": env.Str(MAVEN_PASS),
    63  	}, "mvn",
    64  		"org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file",
    65  		"--settings=bin/package/android/mvn.settings",
    66  		"-DrepositoryId="+REPOSITORY_ID,
    67  		"-Durl="+REPOSITORY_URL,
    68  		"-DpomFile="+artifactBaseName+".pom",
    69  		"-Dfile="+artifactBaseName+".aar",
    70  		"-Dpackaging=aar",
    71  	); err != nil {
    72  		return err
    73  	}
    74  
    75  	// Deploy sources JAR
    76  	if err := sh.RunWithV(map[string]string{
    77  		"MAVEN_USER": env.Str(MAVEN_USER),
    78  		"MAVEN_PASS": env.Str(MAVEN_PASS),
    79  	}, "mvn",
    80  		"org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file",
    81  		"--settings=bin/package/android/mvn.settings",
    82  		"-DrepositoryId="+REPOSITORY_ID,
    83  		"-Durl="+REPOSITORY_URL,
    84  		"-DpomFile="+artifactBaseName+".pom",
    85  		"-Dfile="+artifactBaseName+"-sources.jar",
    86  		"-Dpackaging=jar",
    87  		"-Dclassifier=sources",
    88  	); err != nil {
    89  		return err
    90  	}
    91  
    92  	return nil
    93  }
    94  
    95  // ReleaseAndroidProviderSDK releases tag Android Provider SDK to maven repo.
    96  func ReleaseAndroidProviderSDK() error {
    97  	logconfig.Bootstrap()
    98  
    99  	if err := env.EnsureEnvVars(env.TagBuild, env.BuildVersion); err != nil {
   100  		return err
   101  	}
   102  	job.Precondition(func() bool {
   103  		return env.Bool(env.TagBuild)
   104  	})
   105  
   106  	if err := storage.DownloadArtifacts(); err != nil {
   107  		return err
   108  	}
   109  
   110  	artifactBaseName := fmt.Sprintf("build/package/provider-mobile-node-%s", env.Str(env.BuildVersion))
   111  
   112  	// Deploy AAR (android archive)
   113  	if err := sh.RunWithV(map[string]string{
   114  		"MAVEN_USER": env.Str(MAVEN_USER),
   115  		"MAVEN_PASS": env.Str(MAVEN_PASS),
   116  	}, "mvn",
   117  		"org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file",
   118  		"--settings=bin/package/android_provider/mvn.settings",
   119  		"-DrepositoryId="+REPOSITORY_ID,
   120  		"-Durl="+REPOSITORY_URL,
   121  		"-DpomFile="+artifactBaseName+".pom",
   122  		"-Dfile="+artifactBaseName+".aar",
   123  		"-Dpackaging=aar",
   124  	); err != nil {
   125  		return err
   126  	}
   127  
   128  	// Deploy sources JAR
   129  	if err := sh.RunWithV(map[string]string{
   130  		"MAVEN_USER": env.Str(MAVEN_USER),
   131  		"MAVEN_PASS": env.Str(MAVEN_PASS),
   132  	}, "mvn",
   133  		"org.apache.maven.plugins:maven-gpg-plugin:3.1.0:sign-and-deploy-file",
   134  		"--settings=bin/package/android_provider/mvn.settings",
   135  		"-DrepositoryId="+REPOSITORY_ID,
   136  		"-Durl="+REPOSITORY_URL,
   137  		"-DpomFile="+artifactBaseName+".pom",
   138  		"-Dfile="+artifactBaseName+"-sources.jar",
   139  		"-Dpackaging=jar",
   140  		"-Dclassifier=sources",
   141  	); err != nil {
   142  		return err
   143  	}
   144  
   145  	return nil
   146  }