Fix: update workflow branch trigger to master #1
This file contains hidden or 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: Build and Publish | |
| on: | |
| push: | |
| branches: [ master ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ master ] | |
| jobs: | |
| build-windows: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pyinstaller | |
| - name: Build with PyInstaller | |
| run: | | |
| pyinstaller --onefile --windowed --add-data "assets;assets" --add-data "annotator_libs;annotator_libs" --name ethoscore ethoscore.py | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: windows-exe | |
| path: dist/ethoscore.exe | |
| build-linux: | |
| runs-on: ubuntu-20.04 | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pyinstaller | |
| - name: Build with PyInstaller | |
| run: | | |
| pyinstaller --onefile --add-data "assets:assets" --add-data "annotator_libs:annotator_libs" --name ethoscore ethoscore.py | |
| - name: Create AppImage | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libfuse2 | |
| wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage | |
| chmod +x linuxdeploy-x86_64.AppImage | |
| # Prepare AppDir | |
| mkdir -p AppDir | |
| cp dist/ethoscore AppDir/ | |
| cp ethoscore.desktop AppDir/ | |
| cp assets/controller-logo.svg AppDir/ethoscore.svg | |
| # Run linuxdeploy | |
| # We use --appimage-extract-and-run because we are inside a container/VM that might not have FUSE | |
| export ARCH=x86_64 | |
| ./linuxdeploy-x86_64.AppImage --appimage-extract-and-run --appdir AppDir -d ethoscore.desktop -i AppDir/ethoscore.svg --output appimage | |
| # Rename output | |
| mv Ethoscore-x86_64.AppImage dist/ethoscore.AppImage | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: linux-appimage | |
| path: dist/ethoscore.AppImage | |
| publish: | |
| needs: [build-windows, build-linux] | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download Windows Artifact | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: windows-exe | |
| path: ./publish | |
| - name: Download Linux Artifact | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: linux-appimage | |
| path: ./publish | |
| - name: Create Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| artifacts: "./publish/*" | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| generateReleaseNotes: true | |
| allowUpdates: true | |
| tag: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'latest' }} | |
| name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || 'Latest Build' }} | |
| prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }} |