blob: 1ad96c0ce40e6b8aa13d31791712186db88cc172 [file] [log] [blame]
Søren Gjessee6087bf2023-01-17 10:49:29 +01001#!/usr/bin/env python3
2# Copyright (c) 2023, the R8 project authors. Please see the AUTHORS file
3# for details. All rights reserved. Use of this source code is governed by a
4# BSD-style license that can be found in the LICENSE file.
5
6import re
7import subprocess
8
9GMAVEN_PUBLISHER = '/google/bin/releases/android-devtools/gmaven/publisher/gmaven-publisher'
10GMAVEN_PUBLISH_STAGE_RELEASE_ID_PATTERN = re.compile('Release ID = ([0-9a-f\-]+)')
11
12
13def publisher_stage(gfiles, dry_run = False):
14 if dry_run:
15 print('Dry-run, would have staged %s' % gfiles)
16 return 'dry-run-release-id'
17
18 print("Staging: %s" % ', '.join(gfiles))
19 print("")
20
21 cmd = [GMAVEN_PUBLISHER, 'stage', '--gfile', ','.join(gfiles)]
22 output = subprocess.check_output(cmd)
23
24 # Expect output to contain:
25 # [INFO] 06/19/2020 09:35:12 CEST: >>>>>>>>>> Staged
26 # [INFO] 06/19/2020 09:35:12 CEST: Release ID = 9171d015-18f6-4a90-9984-1c362589dc1b
27 # [INFO] 06/19/2020 09:35:12 CEST: Stage Path = /bigstore/studio_staging/maven2/sgjesse/9171d015-18f6-4a90-9984-1c362589dc1b
28
29 matches = GMAVEN_PUBLISH_STAGE_RELEASE_ID_PATTERN.findall(output.decode("utf-8"))
30 if matches == None or len(matches) > 1:
31 print("Could not determine the release ID from the gmaven_publisher " +
32 "output. Expected a line with 'Release ID = <release id>'.")
33 print("Output was:")
34 print(output)
35 sys.exit(1)
36
37 print(output)
38
39 release_id = matches[0]
40 return release_id
41
42
43def publisher_stage_redir_test_info(release_id, artifact, dst):
44
45 redir_command = ("/google/data/ro/teams/android-devtools-infra/tools/redir "
46 + "--alsologtostderr "
47 + "--gcs_bucket_path=/bigstore/gmaven-staging/${USER}/%s "
48 + "--port=1480") % release_id
49
50 get_command = ("mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:get "
51 + "-Dmaven.repo.local=/tmp/maven_repo_local "
52 + "-DremoteRepositories=http://localhost:1480 "
53 + "-Dartifact=%s "
54 + "-Ddest=%s") % (artifact, dst)
55
56 print("""To test the staged content with 'redir' run:
57
58%s
59
60Then add the following repository to settings.gradle to search the 'redir'
61repository:
62
63dependencyResolutionManagement {
64 repositories {
65 maven {
66 url 'http://localhost:1480'
67 allowInsecureProtocol true
68 }
69 }
70}
71
72and add the following repository to gradle.build for for the staged version:
73
74dependencies {
75 implementation('%s') {
76 changing = true
77 }
78}
79
80Use this commands to get artifact from 'redir':
81
82rm -rf /tmp/maven_repo_local
83%s
84""" % (redir_command, artifact, get_command))
85
86
87def publisher_publish(release_id, dry_run = False):
88 if dry_run:
89 print('Dry-run, would have published %s' % release_id)
90 return
91
92 cmd = [GMAVEN_PUBLISHER, 'publish', release_id]
93 output = subprocess.check_output(cmd)