Skip to content

Commit

Permalink
Release prep
Browse files Browse the repository at this point in the history
  • Loading branch information
John-LittleBearLabs committed May 25, 2023
1 parent 843b10a commit 0e8d229
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmake/chromium.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
build_type = vars['CMAKE_BUILD_TYPE']
python = executable

patcher = Patcher(src,git_binary,build_type)
patcher = Patcher(src, git_binary, build_type)

def run(args, fail_ok = False):
if isdir(src):
Expand Down
24 changes: 15 additions & 9 deletions cmake/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
from os import listdir, remove
from os.path import dirname, join, realpath, splitext
from subprocess import check_call, check_output
from sys import argv, platform, stderr
from sys import argv, executable, platform, stderr
from time import ctime

import requests
try:
import requests
except ModuleNotFoundError:
check_call([executable, '-m', 'pip', 'install', 'requests'])
import requests


def osname():
match platform:
case 'linux':
return 'Linux'
case 'darwn':
return 'Mac'
case _:
return 'Windows'
if platform == 'linux': return 'Linux'
if platform == 'darwin': return 'Mac'
return 'Windows'


class Patcher:
Expand Down Expand Up @@ -160,5 +160,11 @@ def unavailable(self):
missing = Patcher('/mnt/big/lbl/code/chromium/src', 'git', 'Debug').unavailable()
for m in missing:
print(m)
elif argv[1] == 'releases':
p = Patcher('/mnt/big/lbl/code/chromium/src', 'git', 'Debug')
for chan in ['Dev', 'Beta', 'Stable', 'Extended']:
rels = p.release_versions(chan)
for rel in rels:
print(chan, rel)
else:
Patcher(*argv[1:]).create_patch_file()
83 changes: 83 additions & 0 deletions cmake/release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env python3


from version import deduce, on_tag

from os import chdir, environ, getcwd, listdir
from os.path import join, isdir, isfile, splitext
from subprocess import check_call, check_output
from sys import executable, stderr

GITHUB_ORG = 'little-bear-labs'
GITHUB_REPO = 'ipfs-chromium'
# GITHUB_ORG = 'John-LittleBearLabs'
# GITHUB_REPO = 'temp'

try:
from ghapi.all import GhApi
except ModuleNotFoundError:
check_call([executable, '-m', 'pip', 'install', 'ghapi'])
from ghapi.all import GhApi

build_dir = getcwd()


def build_target(target):
argv = ['cmake', '--build', build_dir, '--target', target]
check_call(args=argv)


if not isfile('CMakeCache.txt'):
print(__file__, 'must be run from inside the build directory.', file=stderr)
exit(1)


def line_to_var(line):
try:
colon = line.index(':')
k = line[0:colon]
v = line[colon:]
equal = v.index('=')
return (k, v[equal+1:])
except ValueError:
return ('', None)


vars = check_output(['cmake', '-L', '-N', '-B', '.'], text=True).splitlines()
vars = dict(map(line_to_var, vars))
chromium_out = join(vars['CHROMIUM_SOURCE_TREE'], 'out', vars['CHROMIUM_PROFILE'])
tok = environ.get('GITHUB_TOKEN')
if tok:
gh = GhApi()
else:
print('GITHUB_TOKEN not set!', file=stderr)
exit(2)
build_target('package_browser')
if not isdir(chromium_out):
print(chromium_out, 'is not a directory?!', file=stderr)
exit(3)
build_target('package')
version = deduce()
if on_tag():
print('Will be adding to release', version)
gh_rel = gh.repos.get_release_by_tag(owner=GITHUB_ORG, repo=GITHUB_REPO, tag=version)
else:
print('Creating brand new release!')
gh_rel = gh.repos.create_release(owner=GITHUB_ORG, repo=GITHUB_REPO, tag_name=version)
artifact_extensions = ['.tar.gz', '.rpm', '.deb', '.dmg']


def upload(contains):
for f in listdir('.'):
if contains not in f:
continue
for ext in artifact_extensions:
if f.endswith(ext):
print('Uploading', f, 'to', GITHUB_ORG, GITHUB_REPO, 'release', version)
gh.upload_file(gh_rel, f)
break


upload('client')
chdir(chromium_out)
upload('unstable')
11 changes: 8 additions & 3 deletions cmake/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ def tag_to_version(tag):
return 0


def on_tag():
git(['fetch', '--all', '--tags'])
return git(['describe', '--tags', '--exact-match', 'HEAD'])


def deduce():
on_tag = git(['describe', '--tags', '--exact-match', 'HEAD'])
if on_tag and tag_to_version(on_tag) > 0:
return on_tag
tag = on_tag()
if tag and tag_to_version(tag) > 0:
return tag
git(['fetch', '--tags'])
tags = git(['tag']).splitlines()
versions = map(tag_to_version, tags)
Expand Down
9 changes: 8 additions & 1 deletion library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,15 @@ find_program(RPMBUILD rpmbuild)
if(RPMBUILD)
list(APPEND CPACK_GENERATOR RPM)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
list(APPEND DRAGNDROP)
endif()

set(CPACK_PACKAGE_NAME "ipfs-client-dev-${CMAKE_BUILD_TYPE}")
if (CMAKE_BUILD_TYPE STREQUAL Release)
set(CPACK_PACKAGE_NAME "ipfs-client-devel")
else()
set(CPACK_PACKAGE_NAME "ipfs-client-devel-${CMAKE_BUILD_TYPE}")
endif()
set(CPACK_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}")
set(CPACK_PACKAGE_VENDOR "LBL")
set(CPACK_PACKAGE_CONTACT "[email protected]")
Expand Down

0 comments on commit 0e8d229

Please sign in to comment.