name: New Release (v2) run-name: Release v${{ github.event.inputs.tag }} on: workflow_dispatch: inputs: tag: description: "Version number" required: true default: "0.0.0" binary_build: description: "Build binaries" required: true default: "true" type: choice options: - true - false is_latest: description: "Set as latest" required: true default: "false" type: choice options: - true - false build_docker: description: "Build Docker image" required: true type: choice default: "false" options: - true - false publish_pypi: description: "Publish to PyPI" required: true type: choice default: "false" options: - true - false env: PIP_USE_PEP517: true jobs: build-client: runs-on: ubuntu-latest name: Build client steps: - name: Clone client uses: actions/checkout@v4 with: repository: "swingmx/webclient" path: swingmusic-client - name: Setup Node 20 uses: actions/setup-node@v3 with: node-version: 20.x - name: Install yarn run: | npm install -g yarn - name: Install dependencies & Build client run: | cd swingmusic-client yarn install yarn build --outDir ../client cd .. - name: Upload client uses: actions/upload-artifact@v4 with: path: "client/" compression-level: 0 name: "client" build-wheels: name: Build wheels runs-on: ubuntu-latest needs: [build-client] steps: - name: Checkout swingmusic uses: actions/checkout@v4 with: fetch-depth: 0 - name: Download client artifact uses: actions/download-artifact@v4 with: name: client path: client - name: Compress client and copy to src/swingmusic/client.zip run: | zip -r client.zip client rm -r client cp client.zip src/swingmusic/client.zip - uses: actions/setup-python@v5 with: python-version: "3.11" - name: Create git tag run: | git tag v${{ github.event.inputs.tag }} - name: Build wheels run: pip wheel . -w wheelhouse --no-deps - uses: actions/upload-artifact@v4 with: # name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} path: ./wheelhouse/*.whl compression-level: 0 name: "wheels" build-appimage: name: Build Appimage runs-on: ${{ matrix.os }} needs: [build-client] if: ${{ github.event.inputs.binary_build == 'true' }} strategy: fail-fast: false matrix: os: [ubuntu-latest, ubuntu-24.04-arm] steps: - uses: actions/setup-python@v5 with: python-version: "3.11" - name: Install linux dependencies run: sudo apt-get install libev-dev libfuse-dev -y > /dev/null - name: Checkout swingmusic uses: actions/checkout@v5 with: fetch-depth: 0 sparse-checkout: appimage - name: Set architecture-specific variables run: | if ${{ endsWith(matrix.os, 'arm') }}; then echo "APPIMAGE_ARCH=aarch64" >> $GITHUB_ENV else echo "APPIMAGE_ARCH=x86_64" >> $GITHUB_ENV fi - name: Install appimage builder run: | pip install python-appimage wget -nv -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-$APPIMAGE_ARCH.AppImage" chmod +x "appimagetool-$APPIMAGE_ARCH.AppImage" - name: Download client artifact uses: actions/download-artifact@v4 with: name: client path: client - name: Download wheel artifact uses: actions/download-artifact@v4 with: name: wheels path: wheels merge-multiple: true - name: Build appimage run: | python-appimage build app -p 3.11 appimage/ -n "swingmusic-$APPIMAGE_ARCH" -x client --no-packaging pip install --target "swingmusic-$APPIMAGE_ARCH/opt/python3.11/lib/python3.11/" --no-deps --find-links=wheels/ swingmusic ./appimagetool-$APPIMAGE_ARCH.AppImage --no-appstream "swingmusic-$APPIMAGE_ARCH" "swingmusic-v${{inputs.tag}}-$APPIMAGE_ARCH.AppImage" - uses: actions/upload-artifact@v4 with: path: ./swing*.AppImage compression-level: 0 name: appimage-${{ env.APPIMAGE_ARCH }} docker: name: Build and push Docker image runs-on: ubuntu-latest needs: [build-client, build-wheels] permissions: write-all if: ${{ github.event.inputs.build_docker == 'true' }} steps: - name: Checkout into repo uses: actions/checkout@v3 - name: Create version.txt run: echo ${{ github.event.inputs.tag }} > version.txt - name: Download artifact uses: actions/download-artifact@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v1 - name: Login to GHCR uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Docker meta id: meta # you'll use this in the next step uses: docker/metadata-action@v3 with: # list of Docker images to use as base name for tags images: | ghcr.io/${{ github.repository }} - name: Build and push uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64, linux/arm64 #,linux/arm push: true tags: ghcr.io/${{github.repository}}:${{format('v{0}', github.event.inputs.tag)}}, ${{env.LATEST_TAG}} labels: org.opencontainers.image.title=Docker build-args: | app_version=${{github.event.inputs.tag}} env: LATEST_TAG: ${{ github.event.inputs.is_latest == 'true' && format('ghcr.io/{0}:latest', github.repository) || '' }} build-pyinstaller: name: Build binary on ${{ matrix.os }} runs-on: ${{ matrix.os }} needs: [build-client, build-wheels] if: ${{ github.event.inputs.binary_build == 'true' }} strategy: fail-fast: false matrix: os: [ ubuntu-22.04, ubuntu-22.04-arm, windows-latest, windows-11-arm, # macos-13, macos-latest, ] steps: - name: Checkout swingmusic uses: actions/checkout@v4 with: sparse-checkout: | swingmusic.spec src/swingmusic/assets - name: Install Python 3.11 uses: actions/setup-python@v5 with: python-version: "3.11.x" - name: Download client artifact uses: actions/download-artifact@v4 with: name: client path: client - name: Compress client (Unix) if: runner.os != 'Windows' run: | zip -r client.zip client - name: Compress client (Windows) if: runner.os == 'Windows' run: | Compress-Archive -Path client -DestinationPath client.zip -Force - name: Download wheel artifact uses: actions/download-artifact@v4 with: name: wheels path: wheels merge-multiple: true # install system packages - name: Setup Homebrew if: ${{ startsWith(matrix.os, 'macos') }} uses: Homebrew/actions/setup-homebrew@master - name: Install libev (macOS) if: ${{ startsWith(matrix.os, 'macos') }} run: | brew install libev - name: Install libev (Linux) if: ${{ startsWith(matrix.os, 'ubuntu') }} run: | sudo apt-get install libev-dev -y > /dev/null - name: Install swingmusic run: | pip install --find-links=wheels/ swingmusic[build] - name: Build with Pyinstaller on ${{ matrix.os }} run: pyinstaller swingmusic.spec - name: upload artifact uses: actions/upload-artifact@v4 with: name: Pyinstaller-${{ matrix.os }} path: ./dist/swingmusic_* compression-level: 0 upload-builds: name: Uploading builds to release runs-on: ubuntu-latest needs: [build-client, build-wheels, build-pyinstaller, build-appimage] steps: - name: Checkout swingmusic uses: actions/checkout@v4 with: sparse-checkout: | .github/changelog.md - name: Download client artifact uses: actions/download-artifact@v4 with: name: client path: client - name: compress client run: | zip -r client.zip client rm -r client - name: Download wheel artifacts uses: actions/download-artifact@v4 with: name: wheels path: wheels merge-multiple: true - name: Download all Pyinstaller builds uses: actions/download-artifact@v4 with: pattern: Pyinstaller-* path: pyinstaller merge-multiple: true - name: Download AppImages build uses: actions/download-artifact@v4 with: pattern: appimage* path: appimage merge-multiple: true - name: Upload artifacts to GitHub Release uses: ncipollo/release-action@v1 with: allowUpdates: true draft: true name: ${{ format('v{0}',github.event.inputs.tag) }} tag: ${{ format('v{0}',github.event.inputs.tag) }} bodyFile: .github/changelog.md artifactErrorsFailBuild: true commit: ${{ github.sha }} makeLatest: ${{github.event.inputs.is_latest == 'true'}} artifacts: "client.zip,wheels/*,pyinstaller/*,appimage/*" token: ${{ secrets.PAT }} publish-pypi: name: Publish to PyPI runs-on: ubuntu-latest needs: [build-wheels] if: ${{ github.event.inputs.publish_pypi == 'true' }} permissions: id-token: write steps: - name: Download wheel artifacts uses: actions/download-artifact@v4 with: name: wheels path: dist merge-multiple: true - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: verbose: true