Skip to content

Commit

Permalink
Pull changes to build dir and workflows from main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mosen committed Jan 11, 2024
1 parent 9db7d5c commit 18d4642
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.2'
extensions: mbstring, ldap, mysql
coverage: xdebug
tools: composer:v2, phpunit, phpstan
Expand Down
2 changes: 1 addition & 1 deletion build/mr_upgrade.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/local/munkireport/munkireport-python3

"""Script for upgrading MunkiReport."""

Expand Down
55 changes: 30 additions & 25 deletions build/release/make_munkireport_release.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/python
#!/usr/local/munkireport/munkireport-python3

#
# Script to run the munkireport-php GitHub release workflow as outlined here:
#https://github.com/autopkg/autopkg/wiki/Packaging-AutoPkg-For-Release-on-GitHub
Expand All @@ -15,12 +16,13 @@
import json
import optparse
import os
import plistlib
import certifi
import ssl
import re
import subprocess
import sys
import tempfile
import urllib2
import urllib.request, urllib.error, urllib.parse

from distutils.version import LooseVersion
from pprint import pprint
Expand All @@ -46,25 +48,27 @@ def api_call(endpoint, token, baseurl='https://api.github.com', data=None,
headers = {'Accept': 'application/vnd.github.v3+json',
'Authorization': 'token %s' % token}
if additional_headers:
for header, value in additional_headers.items():
for header, value in list(additional_headers.items()):
headers[header] = value

req = urllib2.Request(baseurl + endpoint, headers=headers)
req = urllib.request.Request(baseurl + endpoint, headers=headers)
try:
results = urllib2.urlopen(req, data=data)
except urllib2.HTTPError as err:
print >> sys.stderr, "HTTP error making API call!"
print >> sys.stderr, err
context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
context.load_verify_locations(certifi.where())
results = urllib.request.urlopen(req, data=data, context=context)
except urllib.error.HTTPError as err:
print("HTTP error making API call!", file=sys.stderr)
print(err, file=sys.stderr)
error_json = err.read()
error = json.loads(error_json)
print >> sys.stderr, "API message: %s" % error['message']
print("API message: %s" % error['message'], file=sys.stderr)
sys.exit(1)
if results:
try:
parsed = json.loads(results.read())
return parsed
except BaseException as err:
print >> sys.stderr, err
print(err, file=sys.stderr)
raise GitHubAPIError
return None

Expand Down Expand Up @@ -104,7 +108,7 @@ def get_version_from_string(str):
return str.split(" ", 1)[0]

def run_command(cmd):
print ' '.join(cmd)
print(' '.join(cmd))
subprocess.check_call(cmd)

def main():
Expand Down Expand Up @@ -147,7 +151,7 @@ def main():
sys.exit("Option --token is required!")
next_version = opts.next_version
if opts.dry_run:
print "Running in 'dry-run' mode.."
print("Running in 'dry-run' mode..")
publish_user, publish_repo = opts.user_repo.split('/')
token = opts.token
release_icon = opts.release_icon
Expand All @@ -166,7 +170,7 @@ def main():
munkireport_root])
os.chdir(munkireport_root)

branch = 'wip'
branch = '5.x'

run_command(['git', 'checkout', branch])

Expand All @@ -187,10 +191,10 @@ def main():
'/repos/%s/%s/releases' % (publish_user, publish_repo), token)
for rel in published_releases:
if rel['tag_name'] == tag_name:
print >> sys.stderr, (
print((
"There's already a published release on GitHub with the tag "
"{0}. It should first be manually removed. "
"Release data printed below:".format(tag_name))
"Release data printed below:".format(tag_name)), file=sys.stderr)
pprint(rel, stream=sys.stderr)
sys.exit()

Expand Down Expand Up @@ -238,20 +242,21 @@ def main():
token,
data=release_data)
if create_release:
print "Release successfully created. Server response:"
print("Release successfully created. Server response:")
pprint(create_release)
print
print()

# increment version
print "Incrementing version to %s.." % next_version
print("Incrementing version to %s.." % next_version)
set_version('%s.%s' % (clean_version(next_version), get_commit_count() + 1))

# increment changelog
new_changelog = "### [{0}](https://github.com/{1}/{2}/compare/v{3}...wip) (Unreleased)\n\n".format(
new_changelog = "### [{0}](https://github.com/{1}/{2}/compare/v{3}...{4}) (Unreleased)\n\n".format(
next_version,
publish_user,
publish_repo,
current_version) + new_changelog
current_version,
branch) + new_changelog
with open(changelog_path, 'w') as fdesc:
fdesc.write(new_changelog)

Expand All @@ -262,12 +267,12 @@ def main():
'Bumping to v%s for development.' % next_version])
if not opts.dry_run:
run_command(['git', 'push', 'origin', branch])
run_command(['git', 'checkout', 'master'])
run_command(['git', 'checkout', 'main'])
run_command(['git', 'merge', tag_name])
run_command(['git', 'push', 'origin', 'master'])
run_command(['git', 'push', 'origin', 'main'])
else:
print ("Ended dry-run mode. Final state of the munkireport-php repo can be "
"found at: %s" % munkireport_root)
print(("Ended dry-run mode. Final state of the munkireport-php repo can be "
"found at: %s" % munkireport_root))
# clean up


Expand Down

0 comments on commit 18d4642

Please sign in to comment.