-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
150 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
import subprocess | ||
|
||
def merge_and_push(): | ||
# Set up paths and branch names | ||
master_branch = 'master' | ||
main_branch = 'main' | ||
commit_message = 'Merge changes from master branch' | ||
|
||
# Fetch latest changes from GitLab | ||
subprocess.run(['git', 'fetch', 'origin']) | ||
|
||
# Checkout the master branch | ||
subprocess.run(['git', 'checkout', master_branch]) | ||
|
||
# Pull latest changes from GitLab | ||
subprocess.run(['git', 'pull', 'origin', master_branch]) | ||
|
||
# Fetch latest changes from GitHub | ||
subprocess.run(['git', 'fetch', 'origin-github']) | ||
|
||
# Checkout the main branch | ||
subprocess.run(['git', 'checkout', main_branch]) | ||
|
||
# Merge the master branch into the main branch | ||
subprocess.run(['git', 'merge', '--no-ff', '-m', commit_message, 'origin/master']) | ||
|
||
# Push changes to the main branch on GitHub | ||
# subprocess.run(['git', 'push', 'origin-github', main_branch]) | ||
|
||
merge_and_push() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
- BBQR support | ||
- Added a new Setting item to use large font in home | ||
- Bug fixes and improvements |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from github import Github, InputGitTreeElement | ||
import base64 | ||
import configparser | ||
import re | ||
|
||
def read_file_content(file_path): | ||
with open(file_path, 'r') as file: | ||
content = file.read() | ||
return content | ||
|
||
def get_version_from_gradle(): | ||
with open('build.gradle', 'r') as f: | ||
content = f.read() | ||
match = re.search(r'def VERSION = "(.*?)"', content) | ||
if match: | ||
return match.group(1) | ||
else: | ||
return None | ||
|
||
def get_github_token(): | ||
config = configparser.RawConfigParser() | ||
with open('local.properties', 'r') as f: | ||
file_content = '[DEFAULT]\n' + f.read() | ||
config.read_string(file_content) | ||
return config.get('DEFAULT', 'githubToken') | ||
|
||
def upload_file_to_github(token, repo_name, file_path, commit_message): | ||
g = Github(token) | ||
version = get_version_from_gradle() | ||
repo = g.get_repo(repo_name) | ||
nunchuk_sdk_repo = g.get_repo("nunchuk-io/nunchuk-android-nativesdk") | ||
release_note = read_file_content('release_note.md') | ||
destination_path = "nunchuk-android-nativesdk-arm8-release.aar" | ||
# Read the file content in binary mode | ||
with open(file_path, 'rb') as file: | ||
file_content = file.read() | ||
|
||
# Encode file content to base64 | ||
file_content_base64 = base64.b64encode(file_content).decode() | ||
|
||
# Get the existing file if it exists | ||
existing_file = repo.get_contents(destination_path) if repo.get_contents(destination_path) else None | ||
|
||
if existing_file: | ||
# If the file exists, get the SHA hash | ||
sha = existing_file.sha | ||
# Determine commit message | ||
commit_message = "File updated via script" | ||
# Update the existing file | ||
repo.update_file(destination_path, commit_message, file_content_base64, sha) | ||
print(f"File '{file_path}' updated successfully at '{destination_path}' in '{repo_name}' repository.") | ||
else: | ||
# Determine commit message | ||
commit_message = "File uploaded via script" | ||
# Create a new file | ||
repo.create_file(destination_path, commit_message, file_content_base64) | ||
print(f"File '{file_path}' uploaded successfully to '{destination_path}' in '{repo_name}' repository.") | ||
|
||
# Create a release | ||
repo.create_git_release(version, version, release_note, draft=True) | ||
nunchuk_sdk_repo.create_git_release(version, version, release_note, draft=True) | ||
print(f"Release '{version}' created successfully with tag '{version}'.") | ||
|
||
# Usage | ||
version = get_version_from_gradle() | ||
github_token = get_github_token() | ||
upload_file_to_github(github_token, "nunchuk-io/nunchuk-android-nativesdk-prebuild", "build/outputs/aar/nunchuk-android-nativesdk-arm8-release.aar", "Upload aar file") |