This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
Add KMP_DUPLICATE_LIB_OK flag to .env file for Windows and Linux builds #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: macos-12 | |
- os: ubuntu-latest | |
python-version: '3.11' | |
target: linux | |
runs-on: ubuntu-latest | |
- os: windows-latest | |
python-version: '3.11' | |
target: windows | |
runs-on: windows-latest | |
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 | |
pip install --upgrade setuptools wheel | |
- name: Install dependencies for MacOS | |
if: matrix.os == 'macos-latest' || matrix.os == 'macos-latest-xlarge' | |
run: | | |
brew install portaudio | |
- 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 | |
echo "KMP_DUPLICATE_LIB_OK=TRUE" >> .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') | |
KMP_DUPLICATE_LIB_OK=TRUE | |
"@ | 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 |