Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Add new files and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
royshil committed Apr 28, 2024
1 parent ca6de49 commit 9809657
Show file tree
Hide file tree
Showing 33 changed files with 5,124 additions and 0 deletions.
174 changes: 174 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
name: Cross-Platform Build with PyInstaller

on:
pull_request:
branches: [ main ]
workflow_call:

jobs:
check-format:
name: Check Formatting 🔍
uses: ./.github/workflows/check-format.yaml
permissions:
contents: read

build:
needs: check-format
strategy:
matrix:
os: [macos-latest, windows-latest] # ubuntu-latest,
include:
- os: macos-latest
python-version: '3.11'
target: macos-x86
runs-on: [self-hosted, macOS]
- os: ubuntu-latest
python-version: '3.11'
target: linux
runs-on: ubuntu-latest
- os: windows-latest
python-version: '3.11'
target: windows
runs-on: [self-hosted, Windows]

runs-on: ${{ matrix.runs-on }}

steps:
- uses: actions/checkout@v4

- name: Set up Python
if: matrix.os != 'windows-latest'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies for Linux
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y portaudio19-dev
- name: Install dependencies
run: |
python -m pip install -r requirements.txt
# - name: Import Apple Certificate
# if: matrix.os == 'macos-latest' || matrix.os == 'macos-latest-xlarge' && github.runner != 'self-hosted'
# run: |
# if security list-keychains | grep -q "github_build.keychain"; then
# security delete-keychain github_build.keychain
# fi
# security create-keychain -p "" github_build.keychain
# security default-keychain -s github_build.keychain
# security set-keychain-settings -lut 21600 github_build.keychain
# echo "${{ secrets.APPLE_CERTIFICATE }}" | base64 --decode > apple_certificate.p12
# security import apple_certificate.p12 -k github_build.keychain -P "${{ secrets.APPLE_CERTIFICATE_PASSWORD }}" \
# -t cert -f pkcs12 -T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/xcrun
# security unlock-keychain -p "" github_build.keychain
# security set-key-partition-list -S 'apple-tool:,apple:' -s -k "" github_build.keychain
# security list-keychain -d user -s github_build.keychain 'login-keychain'
# env:
# APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
# APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}

- name: Unlock keychain on Mac
if: matrix.os == 'macos-latest' || matrix.os == 'macos-latest-xlarge'
run: |
security unlock-keychain -p "" github_build.keychain
security set-key-partition-list -S apple-tool:,apple: -k "" -D "Developer" -t private github_build.keychain
- name: List available signing identities
if: matrix.os == 'macos-latest' || matrix.os == 'macos-latest-xlarge'
run: |
security find-identity -v -p codesigning
# write a .env file with the secrets
- name: Write .env file Mac & Linux
if: matrix.os != 'windows-latest'
run: |
echo "LOCAL_RELEASE_TAG=${GITHUB_REF_NAME}" >> .env
echo "LOCAL_RELEASE_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> .env
- name: Write .env file Windows
if: matrix.os == 'windows-latest'
run: |
@"
LOCAL_RELEASE_TAG=$env:GITHUB_REF_NAME
LOCAL_RELEASE_DATE=$(Get-Date -Format 'yyyy-MM-ddTHH:mm:ssZ')
"@ | Out-File -FilePath .env -Encoding ASCII
shell: pwsh

- name: Build with PyInstaller (MacOS)
if: matrix.os == 'macos-latest' || matrix.os == 'macos-latest-xlarge'
run: |
pyinstaller --clean --noconfirm lexisynth.spec -- --mac_osx
env:
APPLE_APP_DEVELOPER_ID: ${{ secrets.APPLE_APP_DEVELOPER_ID }}

- name: Build with PyInstaller (Windows)
if: matrix.os == 'windows-latest'
run: |
pyinstaller --clean --noconfirm lexisynth.spec -- --win
- name: Build with PyInstaller (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
pyinstaller --clean --noconfirm lexisynth.spec
- name: Zip Application for Notarization
if: matrix.os == 'macos-latest' && github.event_name != 'pull_request'
run: |
ditto -c -k --keepParent dist/lexisynth.app lexisynth.zip
- name: Notarize and Staple
if: matrix.os == 'macos-latest' && github.event_name != 'pull_request'
run: |
xcrun notarytool submit lexisynth.zip --apple-id \
"${{ secrets.APPLE_DEVELOPER_ID_USER }}" --password \
"${{ secrets.APPLE_DEVELOPER_ID_PASSWORD }}" --team-id \
"${{ secrets.APPLE_DEVELOPER_ID_TEAM }}" --wait --verbose
chmod 755 dist/lexisynth.app
xcrun stapler staple dist/lexisynth.app
- name: Verify Notarization
if: matrix.os == 'macos-latest' && github.event_name != 'pull_request'
run: |
spctl -a -v dist/lexisynth.app
rm lexisynth.zip
- name: Compile .ISS to .EXE Installer
if: matrix.os == 'windows-latest'
uses: Minionguyjpro/[email protected]
with:
path: lexisynth.iss
options: /O+

- name: Create tar Linux
if: matrix.os == 'ubuntu-latest'
# strip the folder name from the tar
run: |
chmod a+x dist/lexisynth
tar -cvf lexisynth.tar -C dist lexisynth
- name: Create dmg MacOS
if: matrix.os == 'macos-latest' || matrix.os == 'macos-latest-xlarge'
run: |
chmod a+x dist/lexisynth.app
hdiutil create -volname "LexiSynth" -srcfolder dist/lexisynth.app -ov -format UDZO lexisynth.dmg
- name: Create zip on Windows
if: matrix.os == 'windows-latest'
run: |
Compress-Archive -Path "dist/lexisynth-setup.exe" -DestinationPath "./lexisynth.zip"
shell: pwsh

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: lexisynth-${{ matrix.target }}
# only upload exe on windows, tar on linux, dmg on macos
path: |
lexisynth.dmg
lexisynth.tar
lexisynth.zip
23 changes: 23 additions & 0 deletions .github/workflows/check-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check Python Formatting

on:
workflow_call:

jobs:
check-format:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x

- name: Install dependencies
run: pip install black

- name: Check formatting
run: black --check .
129 changes: 129 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# only run this workflow on the main branch and when a tag is pushed
# this workflow will create a release draft and upload the build artifacts
# to the release draft
name: Release
run-name: ${{ github.ref_name }} release run 🚀
on:
push:
branches:
- main
tags:
- '*'
permissions:
contents: write
concurrency:
group: '${{ github.workflow }} @ ${{ github.ref }}'
cancel-in-progress: ${{ github.ref_type == 'tag' }}
jobs:
build-project:
name: Build Project 🧱
if: github.ref_type == 'tag'
uses: ./.github/workflows/build.yaml
secrets: inherit
permissions:
contents: read

create-release:
name: Create Release 🛫
if: github.ref_type == 'tag'
runs-on: ubuntu-22.04
needs: build-project
defaults:
run:
shell: bash
steps:
- name: Check Release Tag ☑️
id: check
run: |
: Check Release Tag ☑️
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
shopt -s extglob
case "${GITHUB_REF_NAME}" in
+([0-9]).+([0-9]).+([0-9]) )
echo 'validTag=true' >> $GITHUB_OUTPUT
echo 'prerelease=false' >> $GITHUB_OUTPUT
echo "version=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
;;
+([0-9]).+([0-9]).+([0-9])-@(beta|rc)*([0-9]) )
echo 'validTag=true' >> $GITHUB_OUTPUT
echo 'prerelease=true' >> $GITHUB_OUTPUT
echo "version=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT
;;
*) echo 'validTag=false' >> $GITHUB_OUTPUT ;;
esac
- name: Download Build Artifacts 📥
uses: actions/download-artifact@v4
if: fromJSON(steps.check.outputs.validTag)
id: download

- name: Print downloaded artifacts 📥
if: fromJSON(steps.check.outputs.validTag)
run: |
: Print downloaded artifacts 📥
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
shopt -s extglob
ls -laR ${{ steps.download.outputs.artifacts }}
- name: Rename Files 🏷️
if: fromJSON(steps.check.outputs.validTag)
run: |
: Rename Files 🏷️
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
shopt -s extglob
shopt -s nullglob
root_dir="$(pwd)"
commit_hash="${GITHUB_SHA:0:9}"
variants=(
'linux'
'macos-x86'
'windows'
)
mkdir -p "${root_dir}/uploads"
for variant in "${variants[@]}"; do
candidates=(*-${variant}/@(*))
for candidate in "${candidates[@]}"; do
cp "${candidate}" "${root_dir}/uploads/lexisynth-${variant}-${GITHUB_REF_NAME}-${commit_hash}.${candidate##*.}"
done
done
- name: Create Latest Release Info File
if: fromJSON(steps.check.outputs.validTag)
run: |
echo "LATEST_RELEASE_TAG=${GITHUB_REF_NAME}" > release_info.env
echo "LATEST_COMMIT_HASH=${GITHUB_SHA}" >> release_info.env
echo "LATEST_RELEASE_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> release_info.env
cp release_info.env "$(pwd)/uploads/lexisynth_release_info.env"
- name: Generate Checksums 🪪
if: fromJSON(steps.check.outputs.validTag)
run: |
: Generate Checksums 🪪
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
shopt -s extglob
echo "### Checksums" > ${{ github.workspace }}/CHECKSUMS.txt
# find the files from the above step and generate checksums
for file in ${{ github.workspace }}/scoresight-*; do
echo " ${file##*/}: $(sha256sum "${file}" | cut -d " " -f 1)" >> ${{ github.workspace }}/CHECKSUMS.txt
done
- name: Create Release 🛫
if: fromJSON(steps.check.outputs.validTag)
id: create_release
uses: softprops/action-gh-release@v1
with:
draft: true
body_path: ${{ github.workspace }}/CHECKSUMS.txt
files: |
${{ github.workspace }}/lexisynth-*.exe
${{ github.workspace }}/lexisynth-*.dmg
${{ github.workspace }}/lexisynth-*.tar
Loading

0 comments on commit 9809657

Please sign in to comment.