name: New Release run-name: Release v${{ github.event.inputs.tag }} on: workflow_dispatch: inputs: tag: description: "Tag" required: true default: "1.x.x" binary_build: description: "Build platform 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 is_draft: description: "Set as draft" required: true type: choice default: "true" options: - true - false build_docker: description: "Build Docker image" required: true type: choice default: "true" options: - true - false jobs: build: strategy: matrix: os: [ubuntu-20.04, windows-2019] if: ${{ github.event.inputs.binary_build == 'true' }} runs-on: ${{ matrix.os }} name: Create binary on ${{ matrix.os }} steps: - name: Clone client uses: actions/checkout@v3 - name: Setup Node 16 uses: actions/setup-node@v3 with: node-version: 16.x - name: Install yarn run: | npm install -g yarn - name: Clone client run: | git clone https://github.com/cwilvx/swingmusic-client.git - name: Install dependencies & Build client run: | cd swingmusic-client yarn install yarn build --outDir ../client cd .. - name: Install Python 3.10.11 uses: actions/setup-python@v2 with: python-version: "3.10.11" - name: Create virtualenv run: | python -m venv .venv - name: Activate virtualenv (linux) if: matrix.os == 'ubuntu-20.04' run: | apt-get install libev-dev && source .venv/bin/activate && pip install bjoern - name: Activate virtualenv (windows) if: matrix.os == 'windows-2019' run: | .venv\Scripts\Activate && pip install waitress - name: Install dependencies run: | pip install -r requirements.txt # - name: Install Poetry # run: | # pip install poetry # - name: Install dependencies # run: | # python -m poetry install - name: Build server run: | python manage.py --build env: SWINGMUSIC_APP_VERSION: ${{ inputs.tag }} - name: Rename Linux binary if: matrix.os == 'ubuntu-20.04' run: | mv dist/swingmusic dist/swingmusic_linux_amd64 - name: Verify Linux build success if: matrix.os == 'ubuntu-20.04' run: | if [ ! -f "./dist/swingmusic_linux_amd64" ]; then echo "Build failed" exit 1 fi - name: Verify Windows build success if: matrix.os == 'windows-2019' run: | if (-not (Test-Path "./dist/swingmusic.exe")) { Write-Host "Build failed" exit 1 } - name: Upload Linux binary if: matrix.os == 'ubuntu-20.04' uses: actions/upload-artifact@v4 with: name: linux path: dist/swingmusic_linux_amd64 retention-days: 1 - name: Upload Windows binary if: matrix.os == 'windows-2019' uses: actions/upload-artifact@v4 with: name: win32 path: dist/swingmusic.exe retention-days: 1 build_aarch64: runs-on: [ubuntu-20.04] name: Building aarch64 binary steps: - name: Checking out buildscript uses: actions/checkout@v4 with: sparse-checkout: | aarch64_buildscript sparse-checkout-cone-mode: false - name: Installing Packages run: | sudo apt -qq update -y > /dev/null sudo apt -y -qq install binfmt-support qemu-user-static systemd-container wget > /dev/null - name: Starting Services run: | sudo systemctl restart systemd-binfmt sudo systemctl start systemd-resolved - name: Downloading Arch Linux Arm Tarball for rpi4 aarch64 run: | wget -q http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz - name: Extracting Tarball run: | mkdir root sudo tar xpf ArchLinuxARM-rpi-aarch64-latest.tar.gz -C root --warning=no-unknown-keyword - name: Building Swingmusic in qemu run: | chmod +x aarch64_buildscript sed -i -e 's/TAG/${{ github.event.inputs.tag }}/g' aarch64_buildscript mv aarch64_buildscript root/ sudo systemd-nspawn --bind-ro=/etc/resolv.conf -D root ./aarch64_buildscript - name: Upload aarch64 binary uses: actions/upload-artifact@v4 with: name: arm64 path: root/swingmusicbuilder/swingmusic/dist/swingmusic_linux_arm64 retention-days: 1 release: name: Create New Release runs-on: ubuntu-latest needs: [build, build_aarch64] permissions: write-all steps: - name: Checkout into repo uses: actions/checkout@v3 - name: Download all binaries uses: actions/download-artifact@v4 - name: Upload binaries to GitHub Release uses: ncipollo/release-action@v1 with: allowUpdates: true artifacts: "./linux/swingmusic_linux_amd64, ./win32/swingmusic.exe, ./arm64/swingmusic_linux_arm64" token: ${{ secrets.GITHUB_TOKEN }} tag: ${{ format('v{0}',inputs.tag) }} commit: ${{ github.sha }} draft: ${{ inputs.is_draft }} artifactErrorsFailBuild: true name: ${{ format('v{0}',inputs.tag) }} bodyFile: .github/changelog.md makeLatest: ${{ inputs.is_latest }} docker: name: Build and push Docker image runs-on: ubuntu-latest # needs: build permissions: write-all if: inputs.build_docker == 'true' steps: - name: Checkout into repo uses: actions/checkout@v3 # - name: Download linux binary # uses: actions/download-artifact@v3 # with: # name: linux # path: dist - 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@v2 with: context: . platforms: linux/amd64, linux/arm64 #,linux/arm push: true tags: ghcr.io/${{github.repository}}:${{format('v{0}', inputs.tag)}}, ${{env.LATEST_TAG}} labels: org.opencontainers.image.title=Docker build-args: | app_version=${{inputs.tag}} env: LATEST_TAG: ${{ inputs.is_latest == 'true' && format('ghcr.io/{0}:latest', github.repository) || '' }}