From c202f6b219dce15c3e8912f8ff19eac85b0f1e58 Mon Sep 17 00:00:00 2001 From: Tomas Dvorak Date: Wed, 18 Mar 2026 13:25:38 +0100 Subject: [PATCH] ci/cd --- .github/workflows/desktop-ci.yml | 79 +++++++++++++++++------------ .github/workflows/unified-build.yml | 7 ++- src/swingmusic/__init__.py | 10 ++++ 3 files changed, 63 insertions(+), 33 deletions(-) create mode 100644 src/swingmusic/__init__.py diff --git a/.github/workflows/desktop-ci.yml b/.github/workflows/desktop-ci.yml index 5b55d31c..e9e7dbab 100644 --- a/.github/workflows/desktop-ci.yml +++ b/.github/workflows/desktop-ci.yml @@ -15,71 +15,76 @@ jobs: test: name: Test Suite runs-on: ubuntu-latest - + steps: - uses: actions/checkout@v4 - + - name: Install dependencies (ubuntu) run: | sudo apt-get update sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf - + - name: Rust setup uses: dtolnay/rust-toolchain@stable - + - name: Rust Cache uses: swatinem/rust-cache@v2 with: workspaces: "swingmusic-desktop -> target" - + - name: Install Tauri CLI run: npm install -g @tauri-apps/cli - + - name: Install desktop dependencies run: | cd swingmusic-desktop npm install - + - name: Run tests run: cd swingmusic-desktop && cargo test - + build-linux: name: Build Linux runs-on: ubuntu-latest needs: test - + steps: - uses: actions/checkout@v4 - + - name: Install dependencies run: | sudo apt-get update sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf - + - name: Rust setup uses: dtolnay/rust-toolchain@stable with: targets: x86_64-unknown-linux-gnu - + - name: Rust Cache uses: swatinem/rust-cache@v2 with: workspaces: "swingmusic-desktop -> target" key: linux-x64 - + - name: Install Tauri CLI run: npm install -g @tauri-apps/cli - + - name: Install desktop dependencies run: | cd swingmusic-desktop npm install - + + - name: Install webclient dependencies + run: | + cd swingmusic-webclient + npm install + - name: Build the app run: | cd swingmusic-desktop npm run tauri build -- --target x86_64-unknown-linux-gnu - + - name: Upload artifacts uses: actions/upload-artifact@v4 with: @@ -88,39 +93,44 @@ jobs: swingmusic-desktop/target/x86_64-unknown-linux-gnu/release/bundle/ !swingmusic-desktop/target/x86_64-unknown-linux-gnu/release/bundle/.*/ retention-days: 30 - + build-windows: name: Build Windows runs-on: windows-latest needs: test - + steps: - uses: actions/checkout@v4 - + - name: Rust setup uses: dtolnay/rust-toolchain@stable with: targets: x86_64-pc-windows-msvc - + - name: Rust Cache uses: swatinem/rust-cache@v2 with: workspaces: "swingmusic-desktop -> target" key: windows-x64 - + - name: Install Tauri CLI run: npm install -g @tauri-apps/cli - + - name: Install desktop dependencies run: | cd swingmusic-desktop npm install - + + - name: Install webclient dependencies + run: | + cd swingmusic-webclient + npm install + - name: Build the app run: | cd swingmusic-desktop npm run tauri build -- --target x86_64-pc-windows-msvc - + - name: Upload artifacts uses: actions/upload-artifact@v4 with: @@ -129,39 +139,44 @@ jobs: swingmusic-desktop/target/x86_64-pc-windows-msvc/release/bundle/ !swingmusic-desktop/target/x86_64-pc-windows-msvc/release/bundle/.*/ retention-days: 30 - + build-macos: name: Build macOS runs-on: macos-latest needs: test - + steps: - uses: actions/checkout@v4 - + - name: Rust setup uses: dtolnay/rust-toolchain@stable with: targets: x86_64-apple-darwin - + - name: Rust Cache uses: swatinem/rust-cache@v2 with: workspaces: "swingmusic-desktop -> target" key: macos-x64 - + - name: Install Tauri CLI run: npm install -g @tauri-apps/cli - + - name: Install desktop dependencies run: | cd swingmusic-desktop npm install - + + - name: Install webclient dependencies + run: | + cd swingmusic-webclient + npm install + - name: Build the app run: | cd swingmusic-desktop npm run tauri build -- --target x86_64-apple-darwin - + - name: Upload artifacts uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/unified-build.yml b/.github/workflows/unified-build.yml index 18111f79..d2245b85 100644 --- a/.github/workflows/unified-build.yml +++ b/.github/workflows/unified-build.yml @@ -211,6 +211,11 @@ jobs: cd swingmusic-desktop npm install + - name: Install webclient dependencies + run: | + cd swingmusic-webclient + npm install + - name: Build the app run: | cd swingmusic-desktop @@ -303,7 +308,7 @@ jobs: if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/v} else - VERSION=$(python -c "import sys; sys.path.insert(0, 'src'); from swingmusic import __version__; print(__version__)") + VERSION=$(python3 -c "import sys; sys.path.insert(0, 'src'); from swingmusic import __version__; print(__version__)") VERSION="$VERSION-${{ github.run_number }}" fi echo "version=$VERSION" >> $GITHUB_OUTPUT diff --git a/src/swingmusic/__init__.py b/src/swingmusic/__init__.py new file mode 100644 index 00000000..17ef7444 --- /dev/null +++ b/src/swingmusic/__init__.py @@ -0,0 +1,10 @@ +import os +from importlib import metadata as importlib_metadata + +try: + __version__ = importlib_metadata.version("swingmusic") +except importlib_metadata.PackageNotFoundError: + # fallback to version.txt + version_file = os.path.join(os.path.dirname(__file__), "..", "..", "version.txt") + with open(version_file, "r") as f: + __version__ = f.read().strip() \ No newline at end of file