Skip to content

Fixed data directory creation on first time run. #276

Fixed data directory creation on first time run.

Fixed data directory creation on first time run. #276

Workflow file for this run

# Copyright 2021-2024 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@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Ubuntu dependencies
run: |
sudo apt update
sudo apt install -y libudev-dev qt6-base-dev qt6-3d-dev
- name: Install python dependencies
run: |
python -VV
python -m pip install --upgrade pip
python -m pip install build wheel pytest babel polib deepl
- name: Copy files to patch build
run: |
cp CHANGELOG.md joulescope_ui/
cp CREDITS.html joulescope_ui/
- name: Check that translations are up-to-date and compile translations
env:
DEEPL_AUTH: ${{ secrets.DEEPL_AUTH }}
run: python ci/translations.py --preserve-create-date --error-if-changed
- name: Update tokens using GitHub secrets
env:
JOULESCOPE_UI_REPORTER_TOKEN: ${{ secrets.JOULESCOPE_UI_REPORTER_TOKEN }}
run: python ci/tokens.py
- name: Build package
run: python -m build
- name: Install package
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@v4
with:
name: sdist
path: dist/*.tar.gz
if-no-files-found: error
build_installers:
name: Build ${{ matrix.os }}, ${{ matrix.dist }}
needs:
- build_sdist
if: github.event_name == 'push'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
dist: ["pyinstaller", "nuitka"]
exclude:
- os: ubuntu-latest
dist: nuitka
- os: macos-latest
dist: nuitka
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install macOS certificates
if: matrix.os == 'macos-latest'
env:
CERTIFICATE_APP: ${{ secrets.MACOS_CERTIFICATE_APP }}
CERTIFICATE_INSTALLER: ${{ secrets.MACOS_CERTIFICATE_INSTALLER }}
CERTIFICATE_APP_PATH: ${{ runner.temp }}/certificate_app.p12
CERTIFICATE_INSTALLER_PATH: ${{ runner.temp }}/certificate_installer.p12
CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
KEYCHAIN_PWD: adrudfkyY45309i58c
KEYCHAIN_PATH: ${{ runner.temp }}/build-keychain-db
# https://developer.apple.com/forums/thread/701581
# https://www.apple.com/certificateauthority/
run: |
echo $CERTIFICATE_APP | base64 --decode -o $CERTIFICATE_APP_PATH
echo $CERTIFICATE_INSTALLER | base64 --decode -o $CERTIFICATE_INSTALLER_PATH
curl -O https://www.apple.com/certificateauthority/DeveloperIDCA.cer
curl -O https://www.apple.com/certificateauthority/DeveloperIDG2CA.cer
curl -O https://www.apple.com/certificateauthority/AppleWWDRCAG2.cer
curl -O https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer
curl -O https://www.apple.com/certificateauthority/AppleRootCA-G2.cer
security create-keychain -p "$KEYCHAIN_PWD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PWD" $KEYCHAIN_PATH
security default-keychain -s $KEYCHAIN_PATH
security import $CERTIFICATE_APP_PATH -P "$CERTIFICATE_PWD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security import $CERTIFICATE_INSTALLER_PATH -P "$CERTIFICATE_PWD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security add-certificates -k $KEYCHAIN_PATH DeveloperIDCA.cer DeveloperIDG2CA.cer AppleWWDRCAG2.cer AppleWWDRCAG3.cer AppleRootCA-G2.cer
- name: Windows AzureSignTool install
# https://melatonin.dev/blog/how-to-code-sign-windows-installers-with-an-ev-cert-on-github-actions/
if: matrix.os == 'windows-latest'
run: dotnet tool install --global AzureSignTool
- name: Install Ubuntu dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update
sudo apt install -y libudev-dev qt6-base-dev qt6-3d-dev
- name: Install python dependencies
run: |
which python
python -VV
python -m pip install --upgrade pip
python -m pip install -U --upgrade-strategy eager -r requirements.txt
python -m pip install babel polib deepl
- name: Patch macOS to universal2
run: python ci/macos_universal2.py
- name: Update tokens using GitHub secrets
env:
JOULESCOPE_UI_REPORTER_TOKEN: ${{ secrets.JOULESCOPE_UI_REPORTER_TOKEN }}
run: python ci/tokens.py
- name: Compile translations
run: python ci/translations.py --compile-only
- name: Create local files
run: python setup.py sdist
- name: Build with Nuitka
if: matrix.dist == 'nuitka'
run: |
pip install "git+https://${{ secrets.NUITKA_TOKEN }}@github.com/Nuitka/Nuitka-commercial.git@2.1.6#egg=nuitka"
python ci/nuitka_build.py
- name: Save Nuitka report
if: matrix.dist == 'nuitka'
uses: actions/upload-artifact@v4
with:
name: nuitka_report-${{ matrix.os }}-${{ matrix.dist }}
path: nuitka_report.xml
- name: Build with PyInstaller
if: matrix.dist == 'pyinstaller'
run: pyinstaller joulescope.spec
- name: Build Windows installer
if: matrix.os == 'windows-latest'
env:
AZURE_KEY_VAULT_URI: ${{ secrets.AZURE_KEY_VAULT_URI }}
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_CERT_NAME: ${{ secrets.AZURE_CERT_NAME }}
run: python ci/windows_installer.py ${{ matrix.dist }}
- name: Find installer filename
shell: bash
id: installer_filename
run: echo "filename=$(ls dist_installer/*.*)" >> $GITHUB_OUTPUT
- name: macOS notarize
if: matrix.os == 'macos-latest' && github.event_name == 'push' && startswith(github.ref, 'refs/tags/v')
env:
APPLE_ID: ${{ secrets.MACOS_NOTARYTOOL_APPLE_ID }}
NOTARYTOOL_PWD: ${{ secrets.MACOS_NOTARYTOOL_PWD }}
# https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/customizing_the_notarization_workflow
run: |
ls -al ${{ steps.installer_filename.outputs.filename }}
xcrun notarytool submit ${{ steps.installer_filename.outputs.filename }} --apple-id "$APPLE_ID" --team-id "WFRS3L8Y7Y" --password "$NOTARYTOOL_PWD" --wait
xcrun stapler staple ${{ steps.installer_filename.outputs.filename }}
- name: Save changelog
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: installers-changelog
path: CHANGELOG.md
if-no-files-found: error
- name: Save installer artifact
uses: actions/upload-artifact@v4
with:
name: installers-${{ matrix.os }}-${{ matrix.dist }}
path: dist_installer/*
if-no-files-found: error
publish:
name: Publish installers
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/v')
needs:
- build_sdist
- build_installers
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: Download python sdist artifacts
uses: actions/download-artifact@v4
with:
name: sdist
path: dist/
- name: Download installer artifact
uses: actions/download-artifact@v4
with:
pattern: installers-*
merge-multiple: true
path: dist_installer/
- name: Display artifacts
shell: bash
run: ls dist_installer/*
- name: Publish packages to PyPi
uses: pypa/gh-action-pypi-publish@v1.8.11
with:
print-hash: true
- name: Publish Release assets
uses: softprops/action-gh-release@v1
with:
files: |
dist_installer/*