Created
July 18, 2023 06:55
-
-
Save CristianMG/b3f50e354e5007040bbf1eca64d671ba to your computer and use it in GitHub Desktop.
Import artifacts to Github registry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
# Función para recorrer las carpetas y buscar archivos pom.xml | |
def buscar_pom_xml(directorio): | |
for root, dirs, files in os.walk(directorio): | |
print(f"Exploring dirs: {root}") | |
for file in files: | |
if file.endswith(".pom"): | |
print(f"Founded file pom.xml: {file}") | |
ruta_archivo_pom = os.path.join(root, file) | |
nombre_carpeta = os.path.dirname(ruta_archivo_pom) | |
archivo_aar = None | |
for archivo in os.listdir(nombre_carpeta): | |
if archivo.endswith('.aar'): | |
archivo_aar = os.path.join(nombre_carpeta, archivo) | |
print(f"Encontrado archivo .aar: {archivo}") | |
break | |
if archivo_aar: | |
comando = f"mvn org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file \ | |
-DpomFile={ruta_archivo_pom} \ | |
-Dfile={archivo_aar} \ | |
-Durl= URL_GITHUB_REPOSITORY \ | |
-DrepositoryId=github \ | |
-Dtoken= GITHUB_TOKEN_PAT_ACCESS_REGISTRY " | |
print("Executing command:") | |
print(comando) | |
os.system(comando) | |
else: | |
print("Not found aar file .aar at the same folder as pom.xml") | |
# Llamada a la función principal | |
directorio_actual = os.getcwd() | |
print(f"Current directory: {directorio_actual}\n") | |
buscar_pom_xml(directorio_actual) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Required this in your home maven directory ~/.m2/settings.xml