Skip to content

[rna] add package publishing support #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {
id("com.facebook.react.codegen")
id("maven-publish")
id("de.undercouch.download")
id("com.google.cloud.artifactregistry.gradle-plugin") version "2.1.1"
}

import java.nio.file.Paths
Expand Down Expand Up @@ -597,8 +598,8 @@ afterEvaluate {

repositories {
maven {
name = "npm"
url = AAR_OUTPUT_URL
name = "discord"
url = uri("gcs://discord-maven")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ReactAndroid/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=0.66.4
VERSION_NAME=0.66.4-discord-1
GROUP=com.facebook.react

POM_NAME=ReactNative
Expand Down
66 changes: 66 additions & 0 deletions discord/bump_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env python3

from pathlib import Path
from typing import List
import re
import subprocess
import sys


def check_output(args: List[str]) -> str:
return subprocess.check_output(args).decode('utf-8').strip()


VERSION_MATCHER = re.compile(r'^(.*)-discord-(\d*)$')

status = check_output(['git', 'status', '--porcelain'])
if status != '':
print('Detected changed files, please remove or commit them first.\n')
print(status)
sys.exit(1)


root = check_output(['git', 'rev-parse', '--show-toplevel'])
android_path = Path(root) / "ReactAndroid"
props_path = android_path / "gradle.properties"

version = None
property_lines = [line.strip() for line in props_path.read_text().splitlines()]
for line in property_lines:
if line.startswith("VERSION_NAME="):
version = line.split('=')[1]

assert version, "unable to find current version"

matches = VERSION_MATCHER.match(version)
assert matches, f'{version} did not match expected format, X.Y.Z-discord-N'

upstream = matches[1]
local = int(matches[2])

new_version = f'{upstream}-discord-{local + 1}'

with open(props_path, 'w') as f:
for line in property_lines:
if line.startswith("VERSION_NAME="):
f.write(f'VERSION_NAME={new_version}\n')
else:
f.write(f'{line}\n')


branch_name = check_output(['git', 'symbolic-ref', '--short', 'HEAD'])

subprocess.check_call(
['../gradlew', 'publishReleasePublicationToDiscordRepository'],
cwd=android_path.absolute()
)

subprocess.check_call(['git', 'add', props_path.absolute()])
subprocess.check_call(['git', 'commit', '-m', f'version bump: {new_version}'])
subprocess.check_call(['git', 'push', 'origin', branch_name])

new_commit = check_output(['git', 'rev-parse', 'HEAD'])


print(f'NEW TAGGED VERSION: {new_version}')
print(f'NEW COMMIT: {new_commit}')