Skip to content

Commit

Permalink
Add GitHub Actions workflow for building and releasing project
Browse files Browse the repository at this point in the history
* **.github/workflows/build-and-release.yml**
  - Add a new GitHub Actions workflow file to build the project with pyinstaller for Linux, Windows, and Mac.
  - Make the workflow runnable when triggered manually via the GitHub Actions interface.
  • Loading branch information
chicco-carone committed Oct 29, 2024
1 parent 6fce348 commit bca4eef
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
76 changes: 76 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build and Release

on:
workflow_dispatch:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build executable
run: |
if [ ${{ runner.os }} == 'Linux' ]; then
pyinstaller --onefile --name "snapcast-gui" --add-data "icons/Snapcast.png:icons" --add-data "icons/Github.png:icons" main.py
elif [ ${{ runner.os }} == 'Windows' ]; then
pyinstaller --onefile --name "snapcast-gui" --add-data "icons/Snapcast.png;icons" --add-data "icons/Github.png;icons" --uac-admin main.py
elif [ ${{ runner.os }} == 'macOS' ]; then
pyinstaller --onefile --name "snapcast-gui" --add-data "icons/Snapcast.png:icons" --add-data "icons/Github.png:icons" main.py
fi
- name: Archive build artifacts
uses: actions/upload-artifact@v2
with:
name: snapcast-gui-${{ runner.os }}
path: dist/snapcast-gui

release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: snapcast-gui-${{ matrix.os }}
path: dist/

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/snapcast-gui
asset_name: snapcast-gui-${{ matrix.os }}
asset_content_type: application/octet-stream
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,20 @@ Project Link: <https://github.com/chicco-carone/Snapcast-Gui>

<p align="right">(<a href="#readme-top">back to top</a>)</p>

[product-screenshot]: images/screenshot.png
## Using the GitHub Actions Workflow

The project now includes a GitHub Actions workflow to build the project with pyinstaller for Linux, Windows, and Mac, and to create and publish a new release with prebuilt binaries.

### Steps to Use the Workflow

1. **Trigger the Workflow:**
- The workflow is triggered automatically on every push to the `main` branch and on every pull request to the `main` branch.

2. **Build and Release:**
- The workflow builds the project with pyinstaller for Linux, Windows, and Mac.
- It then creates and publishes a new release with prebuilt binaries to the GitHub releases page.

3. **Check the Release:**
- Go to the [releases](https://github.com/chicco-carone/Snapcast-Gui/releases) page to find the newly created release with prebuilt binaries for your platform.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

0 comments on commit bca4eef

Please sign in to comment.