Skip to content

Commit

Permalink
Added GitHub Actions build.
Browse files Browse the repository at this point in the history
* Switched to "stable" update channel by default.
  • Loading branch information
mliberty1 committed Jun 8, 2023
1 parent a25485a commit 7427674
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 47 deletions.
143 changes: 143 additions & 0 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Copyright 2021-2023 Jetperch LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# GitHub actions
# See documentation: https://docs.github.com/en/actions
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# CMake example: https://github.com/Mizux/cmake-cpp/blob/main/.github/workflows/amd64_windows.yml


name: Packaging

on: ['push', 'pull_request']


env:
PYTHON_VERSION: '3.11'


jobs:

build_sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- name: Display info
run: |
echo "github.event_name=$GITHUB_EVENT_NAME"
echo "github.ref=$GITHUB_REF"
echo "github.ref_type=$GITHUB_REF_TYPE"
echo "runner.os=$RUNNER_OS"
echo "runner.arch=$RUNNER_ARCH"
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Display version
run: python -VV

- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build wheel pytest
- name: Build sdist
run: python -m build --sdist

- name: Install the wheel
run: python -m pip install -f dist joulescope_ui

- name: Run python unit tests
run: pytest --pyargs joulescope_ui

- name: Upload python source package
uses: actions/upload-artifact@v3
with:
name: sdist
path: dist/*.tar.gz
if-no-files-found: error

build_installers:
name: Build on ${{ matrix.os }}
if: github.event_name == 'push' # self-hosted windows installer, security concern
needs:
- build_sdist
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]

steps:
- name: Download sdist
uses: actions/download-artifact@v3
with:
name: sdist
path: dist/

- name: Find sdist filename
shell: bash
id: find_sdist_filename
run: echo "filename=$(ls dist/*.tar.gz)" >> $GITHUB_OUTPUT

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install joulescope_ui
- name: Build installer
run: pyinstaller joulescope.spec

- name: Upload installer
uses: actions/upload-artifact@v3
with:
name: installers
path: install/*
if-no-files-found: error

publish:
name: Publish installers
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/v')
needs:
- build_installers
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Download installer artifact
uses: actions/download-artifact@v3
with:
name: installers
path: installers/

- name: Display artifacts
shell: bash
run: ls installers/*

- name: Publish Release assets
uses: softprops/action-gh-release@v1
with:
files: |
installers/*
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ This file contains the list of changes made to pyjoulescope_ui.

---


## 1.0.21

2023 Jun 8

* Switched to "stable" update channel by default.
* Added GitHub Actions build.


## 1.0.20

2023 Jun 1
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ include CHANGELOG.md
include CREDITS.html
include LICENSE.txt
include README.md
recursive-include joulescope_ui *.svg *.json *.qss *.rcc *.html *.md *.txt
recursive-include joulescope_ui *.svg *.json *.qss *.rcc *.html *.md *.txt *.py
include joulescope_ui/test/*.jls
4 changes: 2 additions & 2 deletions joulescope.iss
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
; http://www.jrsoftware.org/ishelp/index.php?topic=setup_signtool

#define MyAppName "Joulescope"
#define MyAppVersion "1.0.20"
#define MyAppVersionUnderscores "1_0_20"
#define MyAppVersion "1.0.21"
#define MyAppVersionUnderscores "1_0_21"
#define MyAppPublisher "Jetperch LLC"
#define MyAppURL "https://www.joulescope.com"
#define MyAppExeName "joulescope.exe"
Expand Down
61 changes: 37 additions & 24 deletions joulescope.spec
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ coll = COLLECT(
)


is_ci = os.environ.get('CI', False)
os.makedirs('install', exist_ok=True)


if sys.platform.startswith('darwin'):
# https://blog.macsales.com/28492-create-your-own-custom-icons-in-10-7-5-or-later
# iconutil --convert icns joulescope_ui/resources/icon.iconset
Expand All @@ -177,38 +181,47 @@ if sys.platform.startswith('darwin'):

print('unsign app')
subprocess.run(['codesign', '--remove', '--all-architectures',
'./dist/joulescope.app'],
cwd=specpath)
print('sign app')
subprocess.run(['codesign',
'-s', MACOS_CODE_SIGN,
'--options', 'runtime',
'--entitlements', './entitlements.plist',
'--deep', './dist/joulescope.app'],
'./dist/joulescope.app'],
cwd=specpath)

# subprocess.run(['hdiutil', 'create', './dist/joulescope_%s.dmg' % VERSION_STR,
# '-srcfolder', './dist/joulescope.app', '-ov'],
# cwd=specpath)
print('create dmg')
dmg_file = 'dist/joulescope_%s.dmg' % VERSION_STR
subprocess.run(['./node_modules/appdmg/bin/appdmg.js', 'appdmg.json', dmg_file])

# xcrun altool --notarize-app --primary-bundle-id "com.jetperch.joulescope" --username "matt.liberty@jetperch.com" --password "@keychain:Developer-altool" --file "dist/joulescope_0_9_11.dmg"
# xcrun altool --notarization-info "7c927036-3c17-4f03-ba24-d49420b1e81d" --username "matt.liberty@jetperch.com" --password "@keychain:Developer-altool"
# spctl -a -t open --context context:primary-signature dmg_file
# xcrun stapler staple dist/joulescope_0_9_11.dmg
if is_ci:
subprocess.run(['tar', 'czvf',
'../install/joulescope_%s.app.tar.gz' % VERSION_STR,
'joulescope.app'],
cwd=os.path.join(specpath, 'dist'))
else:
print('sign app')
subprocess.run(['codesign',
'-s', MACOS_CODE_SIGN,
'--options', 'runtime',
'--entitlements', './entitlements.plist',
'--deep', './dist/joulescope.app'],
cwd=specpath)

# subprocess.run(['hdiutil', 'create', './dist/joulescope_%s.dmg' % VERSION_STR,
# '-srcfolder', './dist/joulescope.app', '-ov'],
# cwd=specpath)
print('create dmg')
dmg_file = 'install/joulescope_%s.dmg' % VERSION_STR
subprocess.run(['./node_modules/appdmg/bin/appdmg.js', 'appdmg.json', dmg_file])

# xcrun altool --notarize-app --primary-bundle-id "com.jetperch.joulescope" --username "matt.liberty@jetperch.com" --password "@keychain:Developer-altool" --file "dist/joulescope_0_9_11.dmg"
# xcrun altool --notarization-info "7c927036-3c17-4f03-ba24-d49420b1e81d" --username "matt.liberty@jetperch.com" --password "@keychain:Developer-altool"
# spctl -a -t open --context context:primary-signature dmg_file
# xcrun stapler staple dist/joulescope_0_9_11.dmg

elif sys.platform == 'win32':
subprocess.run(['C:\Program Files (x86)\Inno Setup 6\ISCC.exe',
'joulescope.iss'],
cwd=specpath)
if is_ci:
shutil.make_archive(f'install/joulescope_{VERSION_STR}.zip', 'zip', 'dist/joulescope')
else:
subprocess.run(['C:\Program Files (x86)\Inno Setup 6\ISCC.exe',
'joulescope.iss'],
cwd=specpath)

elif sys.platform == 'linux':
os.rename(os.path.join(specpath, 'dist/joulescope'),
os.path.join(specpath, 'dist/joulescope_%s' % VERSION_STR))
subprocess.run(['tar', 'czvf',
'joulescope_%s.tar.gz' % VERSION_STR,
'../install/joulescope_%s.tar.gz' % VERSION_STR,
'joulescope_%s/' % VERSION_STR],
cwd=os.path.join(specpath, 'dist'))

2 changes: 1 addition & 1 deletion joulescope_ui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
'software_update_channel': {
'dtype': 'str',
'brief': N_('The software update channel.'),
'default': 'alpha', # todo change to stable for first stable release
'default': 'stable',
'options': [
['alpha', N_('alpha')],
['beta', N_('beta')],
Expand Down
2 changes: 1 addition & 1 deletion joulescope_ui/pubsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
_PUBSUB_OBJ_ATTR = '__pubsub_obj__'


class PUBSUB_TOPICS: # todo
class PUBSUB_TOPICS: # todo support profiles
PUBSUB_APP_NAME = 'common/settings/name'
PUBSUB_PROFILE_ACTION_ADD = 'common/actions/profile/!add'
PUBSUB_PROFILE_ACTION_REMOVE = 'common/actions/profile/!remove'
Expand Down
7 changes: 0 additions & 7 deletions joulescope_ui/test/cfg1.json5

This file was deleted.

2 changes: 1 addition & 1 deletion joulescope_ui/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.20"
__version__ = "1.0.21"
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2022 Jetperch LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# See https://toml.io/

# A build-system independent format for source trees: https://peps.python.org/pep-0517/
# Specifying Minimum Build System Requirements for Python Projects: https://peps.python.org/pep-0518/
[build-system]
# Minimum requirements for the build system to execute.
requires = [
"PySide6>=6.5.0",
"setuptools>=42",
"wheel",
]
build-backend = "setuptools.build_meta"
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ appnope>=0.1.2
check-manifest>=0.37
coverage>=4.5.2
fs
pyjoulescope_driver>=1.3.12,<2.0.0 # also update JOULESCOPE_DRIVER_VERSION_MIN in setup.py
joulescope>=1.1.6,<2.0.0 # also update JOULESCOPE_VERSION_MIN in setup.py
pyjoulescope_driver>=1.3.14,<2.0.0 # also update JOULESCOPE_DRIVER_VERSION_MIN in setup.py
joulescope>=1.1.7,<2.0.0 # also update JOULESCOPE_VERSION_MIN in setup.py
markdown
psutil
pyjls>=0.7.0
pyjls>=0.7.1
pyopengl
pyperclip>=1.7.0
pywin32; sys_platform == 'win32' # python {path_to_python}\scripts\pywin32_postinstall.py -install
pyqtgraph>=0.13.2
PySide6>=6.4.3,<7.0.0
PySide6>=6.5.0,<7.0.0
PySide6-QtAds>=4.0.3,<5.0.0
python-dateutil>=2.7.3
PyInstaller>=5.0.1
Expand Down
10 changes: 4 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import shutil


JOULESCOPE_DRIVER_VERSION_MIN = '1.3.12' # also update requirements.txt
JOULESCOPE_VERSION_MIN = '1.1.6' # also update requirements.txt
MYPATH = os.path.abspath(os.path.dirname(__file__))
VERSION_PATH = os.path.join(MYPATH, 'joulescope_ui', 'version.py')

Expand Down Expand Up @@ -208,16 +206,16 @@ def run(self):
install_requires=[
'appnope>=0.1.2',
'fs',
f'pyjoulescope_driver>={JOULESCOPE_DRIVER_VERSION_MIN},<2.0.0',
f'joulescope>={JOULESCOPE_VERSION_MIN},<2.0.0',
'pyjoulescope_driver>=1.3.14,<2.0.0',
'joulescope>=1.1.7,<2.0.0',
'markdown',
'psutil',
'pyjls>=0.7.0',
'pyjls>=0.7.1',
'pyopengl',
'pyperclip>=1.7.0',
"pywin32>=223; platform_system == 'Windows'",
'pyqtgraph>=0.13.2',
'PySide6>=6.4.3,<7.0.0',
'PySide6>=6.5.0,<7.0.0',
'PySide6-QtAds>=4.0.3,<5.0.0',
'python-dateutil>=2.7.3',
'QtPy',
Expand Down

0 comments on commit 7427674

Please sign in to comment.