feat: include binaries in the build #7
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 Release | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| # Determine if we should create a release | |
| semantic-release: | |
| name: Semantic Release | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| outputs: | |
| new-release-published: ${{ steps.semantic.outputs.new-release-published }} | |
| new-release-version: ${{ steps.semantic.outputs.new-release-version }} | |
| new-release-git-tag: ${{ steps.semantic.outputs.new-release-git-tag }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ssh-key: ${{ secrets.DEPLOY_KEY }} | |
| - name: Setup Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install semantic-release | |
| run: | | |
| npm install -g semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits | |
| - name: Get next version | |
| id: semantic | |
| run: | | |
| # Run semantic-release in dry-run mode to get the next version | |
| OUTPUT=$(semantic-release --dry-run) | |
| echo "$OUTPUT" | |
| # Extract version from output | |
| VERSION=$(echo "$OUTPUT" | grep -oP 'The next release version is \K[0-9]+\.[0-9]+\.[0-9]+' || echo "") | |
| if [ -n "$VERSION" ]; then | |
| echo "new-release-published=true" >> $GITHUB_OUTPUT | |
| echo "new-release-version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "new-release-git-tag=v$VERSION" >> $GITHUB_OUTPUT | |
| echo "Found new version: $VERSION" | |
| else | |
| echo "new-release-published=false" >> $GITHUB_OUTPUT | |
| echo "No new version needed" | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Build binaries for all platforms | |
| build: | |
| name: Build ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| needs: semantic-release | |
| if: needs.semantic-release.outputs.new-release-published == 'true' | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: windows-latest | |
| name: windows | |
| executable: glimpse.exe | |
| icon: app_icon.ico | |
| - os: ubuntu-latest | |
| name: linux | |
| executable: glimpse | |
| icon: app_icon.png | |
| - os: macos-latest | |
| name: macos | |
| executable: glimpse | |
| icon: app_icon.png | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.13' | |
| - name: Install uv (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| powershell -c "irm https://astral.sh/uv/install.ps1 | iex" | |
| echo "$env:USERPROFILE\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| - name: Install uv (Unix) | |
| if: matrix.os != 'windows-latest' | |
| run: | | |
| curl -LsSf https://astral.sh/uv/install.sh | sh | |
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
| - name: Install system dependencies (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libegl1-mesa-dev \ | |
| libgl1-mesa-dev \ | |
| libxcb-image0 \ | |
| libxcb-keysyms1 \ | |
| libxcb-render-util0 \ | |
| libxcb-xkb1 \ | |
| libxkbcommon-x11-0 \ | |
| xvfb | |
| - name: Install dependencies | |
| run: | | |
| uv pip install --system pyinstaller pyside6 | |
| - name: Create version file | |
| shell: bash | |
| run: | | |
| echo "VERSION = '${{ needs.semantic-release.outputs.new-release-version }}'" > src/version.py | |
| - name: Build executable (Linux with virtual display) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| xvfb-run -a pyinstaller glimpse.spec | |
| - name: Build executable (Windows/macOS) | |
| if: matrix.os != 'ubuntu-latest' | |
| run: | | |
| pyinstaller glimpse.spec | |
| - name: Create archive (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| powershell -command "Compress-Archive -Path dist/glimpse.exe -DestinationPath glimpse-${{ needs.semantic-release.outputs.new-release-version }}-windows-x64.zip" | |
| - name: Create archive (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| cd dist | |
| tar -czf ../glimpse-${{ needs.semantic-release.outputs.new-release-version }}-linux-x64.tar.gz glimpse | |
| cd .. | |
| - name: Create archive (macOS) | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| cd dist | |
| # Create a simple tar.gz for macOS | |
| tar -czf ../glimpse-${{ needs.semantic-release.outputs.new-release-version }}-macos-x64.tar.gz glimpse | |
| cd .. | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: glimpse-${{ matrix.name }} | |
| path: | | |
| glimpse-*.zip | |
| glimpse-*.tar.gz | |
| # Create the actual release with binaries | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: [semantic-release, build] | |
| if: needs.semantic-release.outputs.new-release-published == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ssh-key: ${{ secrets.DEPLOY_KEY }} | |
| - name: Setup Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install semantic-release | |
| run: | | |
| npm install -g semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./artifacts | |
| - name: Display structure of downloaded files | |
| run: ls -R ./artifacts | |
| - name: Prepare release assets | |
| run: | | |
| mkdir -p release-assets | |
| find ./artifacts -name "*.zip" -o -name "*.tar.gz" | xargs -I {} cp {} release-assets/ | |
| ls -la release-assets/ | |
| - name: Create version file for semantic-release | |
| run: | | |
| echo "VERSION = '${{ needs.semantic-release.outputs.new-release-version }}'" > src/version.py | |
| - name: Run semantic-release (full release) | |
| run: semantic-release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload release assets to GitHub release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ needs.semantic-release.outputs.new-release-git-tag }} | |
| files: release-assets/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |