ota-flasher/.forgejo/workflows/build_all.yaml
2024-12-31 12:41:11 +01:00

144 lines
4.5 KiB
YAML

name: Build all artifacts and make release
on:
workflow_dispatch:
inputs:
build:
description: 'Select build type'
required: true
default: 'all'
type: choice
options:
- all
- mac
- windows
- linux
jobs:
build-macos:
if: ${{ github.event.inputs.build == 'all' || github.event.inputs.build == 'mac' }}
runs-on: macos-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download universal2 Python
run: |
curl -o python.pkg https://www.python.org/ftp/python/3.12.4/python-3.12.4-macos11.pkg
- name: Install Python
run: |
sudo installer -pkg python.pkg -target /
- name: Add Python to PATH
run: |
echo "/Library/Frameworks/Python.framework/Versions/3.12/bin" >> $GITHUB_PATH
- name: Verify Python installation
run: |
python3 --version
pip3 --version
- name: Install dependencies
run: |
pip3 install --upgrade pip
pip3 install pyinstaller
pip3 install --no-cache cffi --no-binary :all:
pip3 install --no-cache charset_normalizer --no-binary :all:
pip3 install -U --pre -f https://wxpython.org/Phoenix/snapshot-builds/ wxPython
pip3 install -r requirements.txt
- name: Build with PyInstaller
run: |
pyinstaller BTClockOTA-universal.spec
- name: Zip the app bundle
run: |
cd dist
zip -r BTClockOTA-macos-universal2.zip BTClockOTA.app
- name: Create DMG
run: |
mkdir dmg_temp
cp -R dist/BTClockOTA.app dmg_temp/
# Create the DMG file
hdiutil create -volname "BTClockOTA" -srcfolder dmg_temp -ov -format UDZO "dist/BTClockOTA-universal.dmg"
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: macos-artifacts
path: |
dist/*
!dist/BTClockOTA.app
build-windows:
if: ${{ github.event.inputs.build == 'all' || github.event.inputs.build == 'windows' }}
runs-on: docker-amd64
container:
image: batonogov/pyinstaller-windows:latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build with PyInstaller
run: |
python -m PyInstaller $SPECFILE
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: windows-artifacts
path: dist/
build-linux:
if: ${{ github.event.inputs.build == 'all' || github.event.inputs.build == 'linux' }}
runs-on: docker-amd64
container:
image: ghcr.io/btclock/pyinstaller-wxpython-linux:latest
credentials:
username: dsbaars
password: ${{ secrets.GH_TOKEN }}
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build with PyInstaller
run: |
python -m PyInstaller $SPECFILE &&
mv dist/BTClockOTA dist/BTClockOTA-linux-amd64
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: linux-artifacts
path: dist/
release:
needs: [build-macos, build-windows, build-linux]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get current block
id: getBlockHeight
run: echo "blockHeight=$(curl -s https://mempool.space/api/blocks/tip/height)" >> $GITHUB_OUTPUT
- name: Get Windows Artifacts
if: ${{ always() }}
uses: actions/download-artifact@v4
with:
name: windows-artifacts
path: windows
- name: Get macOS Artifacts
if: ${{ always() }}
uses: actions/download-artifact@v4
with:
name: macos-artifacts
path: macos
- name: Get Linux Artifacts
if: ${{ always() }}
uses: actions/download-artifact@v4
with:
name: linux-artifacts
path: linux
- name: Create release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.getBlockHeight.outputs.blockHeight }}
commit: main
name: release-${{ steps.getBlockHeight.outputs.blockHeight }}
artifacts: "macos/**/*.dmg,macos/**/*.zip,windows/**/*.exe,linux/*"
allowUpdates: true
makeLatest: true