diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f9fdef3..38dffb4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,51 +12,95 @@ permissions: jobs: build: runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + include: + - arch: amd64 + platform: linux/amd64 + artifact_name: crossdesk_server-linux-amd64 + - arch: arm64 + platform: linux/arm64 + artifact_name: crossdesk_server-linux-arm64 steps: - name: Checkout uses: actions/checkout@v4 - - name: Build Docker Image - run: | - IMAGE_NAME=crossdesk-server - IMAGE_TAG=${GITHUB_REF_NAME:-latest} - docker build -t ${IMAGE_NAME}:${IMAGE_TAG} -f docker/Dockerfile . + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - - name: Save built binary as artifact + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build ${{ matrix.arch }} binary artifact + uses: docker/build-push-action@v6 + with: + context: . + file: docker/dockerfile + platforms: ${{ matrix.platform }} + target: artifact + outputs: type=local,dest=./dist + + - name: Rename built binary run: | - docker create --name temp crossdesk-server:${GITHUB_REF_NAME:-latest} - docker cp temp:/crossdesk-server/crossdesk_server ./crossdesk_server - docker rm temp + mv ./dist/crossdesk_server ./dist/${{ matrix.artifact_name }} shell: bash - uses: actions/upload-artifact@v4 with: - name: crossdesk_server - path: crossdesk_server + name: ${{ matrix.artifact_name }} + path: ./dist/${{ matrix.artifact_name }} + + docker-release: + if: startsWith(github.ref, 'refs/tags/') + needs: build + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub - if: startsWith(github.ref, 'refs/tags/') - run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Push Docker image to Docker Hub - if: startsWith(github.ref, 'refs/tags/') - run: | - IMAGE_TAG=${GITHUB_REF_NAME} - DOCKER_USER=${{ secrets.DOCKERHUB_USERNAME }} - IMAGE_NAME=${DOCKER_USER}/crossdesk-server + uses: docker/build-push-action@v6 + with: + context: . + file: docker/dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/crossdesk-server:${{ github.ref_name }} + ${{ secrets.DOCKERHUB_USERNAME }}/crossdesk-server:latest - echo "Pushing ${IMAGE_NAME}:${IMAGE_TAG} and ${IMAGE_NAME}:latest" + release: + if: startsWith(github.ref, 'refs/tags/') + needs: build + runs-on: ubuntu-22.04 - docker tag crossdesk-server:${IMAGE_TAG} ${IMAGE_NAME}:${IMAGE_TAG} - docker tag crossdesk-server:${IMAGE_TAG} ${IMAGE_NAME}:latest + steps: + - name: Download release artifacts + uses: actions/download-artifact@v4 + with: + pattern: crossdesk_server-linux-* + path: dist + merge-multiple: true - docker push ${IMAGE_NAME}:${IMAGE_TAG} - docker push ${IMAGE_NAME}:latest - - - name: Publish GitHub Release (on tag) - if: startsWith(github.ref, 'refs/tags/') + - name: Publish GitHub Release uses: softprops/action-gh-release@v2 with: - files: crossdesk_server + files: | + dist/crossdesk_server-linux-amd64 + dist/crossdesk_server-linux-arm64 generate_release_notes: true diff --git a/docker/dockerfile b/docker/dockerfile index ab236d2..c067e32 100644 --- a/docker/dockerfile +++ b/docker/dockerfile @@ -30,11 +30,26 @@ COPY . . # Build and copy only the binary, clean up build artifacts RUN xmake b -vy --root crossdesk_server && \ mkdir -p /output && \ - cp build/linux/x86_64/release/crossdesk_server /output/ && \ + BINARY_PATH="$(find build -type f -path '*/release/crossdesk_server' | head -n 1)" && \ + test -n "${BINARY_PATH}" && \ + cp "${BINARY_PATH}" /output/crossdesk_server && \ rm -rf build .xmake +FROM scratch AS artifact -FROM crossdesk/crossdesk-server-base:latest +COPY --from=builder /output/crossdesk_server /crossdesk_server + + +FROM ubuntu:22.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + coturn \ + openssl && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Generate coturn certificates and set permissions in one layer RUN mkdir -p /opt/turnserver && \ @@ -50,7 +65,7 @@ RUN mkdir -p /opt/turnserver && \ # Copy files and set permissions in one layer COPY docker/start.sh /start.sh COPY docker/generate_certs.sh /docker/generate_certs.sh -COPY --from=builder /output/crossdesk_server /crossdesk-server/crossdesk_server +COPY --from=artifact /crossdesk_server /crossdesk-server/crossdesk_server RUN chmod +x /start.sh /docker/generate_certs.sh /crossdesk-server/crossdesk_server ENTRYPOINT ["/start.sh"] diff --git a/workflows/build.yaml b/workflows/build.yaml deleted file mode 100644 index f148868..0000000 --- a/workflows/build.yaml +++ /dev/null @@ -1,357 +0,0 @@ -name: Build and Release CrossDesk - -on: - push: - branches: - - "**" - tags: - - "*" - workflow_dispatch: - -permissions: - contents: write - -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -jobs: - # Linux amd64 - build-linux-amd64: - name: Build on Ubuntu 22.04 amd64 - runs-on: ubuntu-22.04 - container: - image: crossdesk/ubuntu20.04:latest - options: --user root - steps: - - name: Extract version number - id: version - run: | - VERSION="${GITHUB_REF##*/}" - VERSION_NUM="${VERSION#v}" - echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_ENV - - - name: Set legal Debian version - shell: bash - id: set_deb_version - run: | - if [[ ! "${VERSION_NUM}" =~ ^[0-9] ]]; then - LEGAL_VERSION="0.0.0-${VERSION_NUM}" - else - LEGAL_VERSION="${VERSION_NUM}" - fi - echo "LEGAL_VERSION=${LEGAL_VERSION}" >> $GITHUB_ENV - - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Build CrossDesk - env: - CUDA_PATH: /usr/local/cuda - XMAKE_GLOBALDIR: /data - run: | - ls -la $XMAKE_GLOBALDIR - xmake b -vy --root crossdesk - - - name: Decode and save certificate - shell: bash - run: | - mkdir -p certs - echo "${{ secrets.CROSSDESK_CERT_BASE64 }}" | base64 --decode > certs/crossdesk.cn_root.crt - - - name: Package - run: | - chmod +x ./scripts/linux/pkg_amd64.sh - ./scripts/linux/pkg_amd64.sh ${LEGAL_VERSION} - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: crossdesk-linux-amd64-${{ env.LEGAL_VERSION }} - path: ${{ github.workspace }}/crossdesk-linux-amd64-${{ env.LEGAL_VERSION }}.deb - - # Linux arm64 - build-linux-arm64: - name: Build on Ubuntu 22.04 arm64 - runs-on: ubuntu-22.04-arm - strategy: - matrix: - include: - - arch: arm64 - image: crossdesk/ubuntu20.04-arm64v8:latest - package_script: ./scripts/linux/pkg_arm64.sh - container: - image: ${{ matrix.image }} - options: --user root - steps: - - name: Extract version number - id: version - run: | - VERSION="${GITHUB_REF##*/}" - VERSION_NUM="${VERSION#v}" - echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_ENV - - - name: Set legal Debian version - shell: bash - id: set_deb_version - run: | - if [[ ! "${VERSION_NUM}" =~ ^[0-9] ]]; then - LEGAL_VERSION="0.0.0-${VERSION_NUM}" - else - LEGAL_VERSION="${VERSION_NUM}" - fi - echo "LEGAL_VERSION=${LEGAL_VERSION}" >> $GITHUB_ENV - - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Build CrossDesk - env: - CUDA_PATH: /usr/local/cuda - XMAKE_GLOBALDIR: /data - run: | - xmake b -vy --root crossdesk - - - name: Decode and save certificate - shell: bash - run: | - mkdir -p certs - echo "${{ secrets.CROSSDESK_CERT_BASE64 }}" | base64 --decode > certs/crossdesk.cn_root.crt - - - name: Package - run: | - chmod +x ${{ matrix.package_script }} - ${{ matrix.package_script }} ${LEGAL_VERSION} - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: crossdesk-linux-${{ matrix.arch }}-${{ env.LEGAL_VERSION }} - path: ${{ github.workspace }}/crossdesk-linux-${{ matrix.arch }}-${{ env.LEGAL_VERSION }}.deb - - # macOS - build-macos: - name: Build on macOS - runs-on: ${{ matrix.runner }} - strategy: - matrix: - include: - - arch: x64 - runner: macos-13 - cache-key: intel - out-dir: ./build/macosx/x86_64/release/crossdesk - package_script: ./scripts/macosx/pkg_x64.sh - - arch: arm64 - runner: macos-14 - cache-key: arm - out-dir: ./build/macosx/arm64/release/crossdesk - package_script: ./scripts/macosx/pkg_arm64.sh - - steps: - - name: Extract version number - id: version - run: | - VERSION="${GITHUB_REF##*/}" - VERSION_NUM="${VERSION#v}" - echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_ENV - echo "VERSION_NUM=${VERSION_NUM}" - - - name: Cache xmake dependencies - uses: actions/cache@v4 - with: - path: ~/.xmake/packages - key: ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}-${{ hashFiles('**/xmake.lua') }} - restore-keys: | - ${{ runner.os }}-xmake-deps-${{ matrix.cache-key }}- - - - name: Install xmake - run: brew install xmake - - - name: Checkout code - uses: actions/checkout@v4 - - - name: Initialize submodules - run: git submodule update --init --recursive - - - name: Build CrossDesk - run: xmake b -vy crossdesk - - - name: Decode and save certificate - shell: bash - run: | - mkdir -p certs - echo "${{ secrets.CROSSDESK_CERT_BASE64 }}" | base64 --decode > certs/crossdesk.cn_root.crt - - - name: Package CrossDesk app - run: | - chmod +x ${{ matrix.package_script }} - ${{ matrix.package_script }} ${VERSION_NUM} - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: crossdesk-macos-${{ matrix.arch }}-${{ env.VERSION_NUM }} - path: crossdesk-macos-${{ matrix.arch }}-${{ env.VERSION_NUM }}.pkg - - - name: Move files to release dir - run: | - mkdir -p release - cp crossdesk-macos-${{ matrix.arch }}-${{ env.VERSION_NUM }}.pkg release/ - - # Windows - build-windows-x64: - name: Build on Windows x64 - runs-on: windows-2022 - env: - XMAKE_GLOBALDIR: D:\xmake_global - steps: - - name: Extract version number - shell: pwsh - run: | - $ref = $env:GITHUB_REF - $version = $ref -replace '^refs/(tags|heads)/', '' - $version = $version -replace '^v', '' - $version = $version -replace '/', '-' - echo "VERSION_NUM=$version" >> $env:GITHUB_ENV - - - name: Cache xmake dependencies - uses: actions/cache@v4 - with: - path: D:\xmake_global\.xmake\packages - key: ${{ runner.os }}-xmake-deps-intel-${{ hashFiles('**/xmake.lua') }} - restore-keys: | - ${{ runner.os }}-xmake-deps-intel- - - - name: Install xmake - run: | - Invoke-Expression (Invoke-Webrequest 'https://raw.githubusercontent.com/tboox/xmake/master/scripts/get.ps1' -UseBasicParsing).Content - echo "C:\Users\runneradmin\xmake" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - xmake create cuda - Set-Location cuda - xmake g --theme=plain - $cudaPath = "" - $packagesPath = "D:\xmake_global\.xmake\packages" - - if (Test-Path $packagesPath) { - Write-Host "Packages directory exists: $packagesPath" - try { - $info = xmake require --info "cuda 12.6.3" 2>$null - if ($null -ne $info -and $info -ne "") { - $cudaPath = (($info | Select-String installdir).ToString() -replace '.*installdir:\s*','').Trim() - } - } catch {} - } else { - Write-Host "Packages directory not found: $packagesPath" - Write-Host "Installing CUDA package..." - xmake require -vy "cuda 12.6.3" - $info = xmake require --info "cuda 12.6.3" - $cudaPath = (($info | Select-String installdir).ToString() -replace '.*installdir:\s*','').Trim() - } - - echo "CUDA_PATH=$cudaPath" >> $env:GITHUB_ENV - Write-Host "Resolved CUDA_PATH = $cudaPath" - Pop-Location - - - name: Checkout code - uses: actions/checkout@v4 - - - name: Initialize submodules - run: git submodule update --init --recursive - - - name: Build CrossDesk - run: xmake b -vy crossdesk - - - name: Decode and save certificate - shell: powershell - run: | - New-Item -ItemType Directory -Force -Path certs - [System.IO.File]::WriteAllBytes('certs\crossdesk.cn_root.crt', [Convert]::FromBase64String('${{ secrets.CROSSDESK_CERT_BASE64 }}')) - - - name: Package - shell: pwsh - run: | - cd "${{ github.workspace }}\scripts\windows" - makensis /DVERSION=$env:VERSION_NUM nsis_script.nsi - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: crossdesk-win-x64-${{ env.VERSION_NUM }} - path: ${{ github.workspace }}/scripts/windows/crossdesk-win-x64-${{ env.VERSION_NUM }}.exe - - release: - name: Publish Release - if: startsWith(github.ref, 'refs/tags/v') - needs: - [build-linux-amd64, build-linux-arm64, build-macos, build-windows-x64] - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Download all artifacts - uses: actions/download-artifact@v4 - with: - path: artifacts - - - name: Extract version number - id: version - run: | - VERSION="${GITHUB_REF##*/}" - VERSION_NUM="${VERSION#v}" - echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_OUTPUT - - - name: Rename artifacts - run: | - mkdir -p release - cp artifacts/crossdesk-macos-x64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-macos-x64-${{ steps.version.outputs.VERSION_NUM }}.pkg - cp artifacts/crossdesk-macos-arm64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-macos-arm64-${{ steps.version.outputs.VERSION_NUM }}.pkg - cp artifacts/crossdesk-linux-amd64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-linux-amd64-${{ steps.version.outputs.VERSION_NUM }}.deb - cp artifacts/crossdesk-linux-arm64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-linux-arm64-${{ steps.version.outputs.VERSION_NUM }}.deb - cp artifacts/crossdesk-win-x64-${{ steps.version.outputs.VERSION_NUM }}/* release/crossdesk-win-x64-${{ steps.version.outputs.VERSION_NUM }}.exe - - - name: List release files - run: ls -lh release/ - - - name: Upload to Versioned GitHub Release - uses: softprops/action-gh-release@v2 - with: - tag_name: v${{ steps.version.outputs.VERSION_NUM }} - name: Release v${{ steps.version.outputs.VERSION_NUM }} - draft: false - prerelease: false - files: release/* - generate_release_notes: false - body: | - Binary release only. Source code is not included. - - - name: Create or update 'latest' tag - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git tag -f latest - git push origin latest --force - - - name: Upload to GitHub Release (latest) - uses: softprops/action-gh-release@v2 - with: - tag_name: latest - name: Latest Release - draft: false - prerelease: false - files: release/* - generate_release_notes: false - - - name: Upload artifacts to server - uses: burnett01/rsync-deployments@5.2 - with: - switches: -avzr --progress --delete - path: release/* - remote_path: /var/www/html/downloads/ - remote_host: ${{ secrets.SERVER_HOST }} - remote_user: ${{ secrets.SERVER_USER }} - remote_key: ${{ secrets.SERVER_KEY }} diff --git a/workflows/update-pages.yaml b/workflows/update-pages.yaml deleted file mode 100644 index 3183c74..0000000 --- a/workflows/update-pages.yaml +++ /dev/null @@ -1,48 +0,0 @@ -name: Update GitHub Pages Downloads - -on: - push: - tags: - - "v*" - -jobs: - update-pages: - runs-on: ubuntu-latest - steps: - - name: Checkout CrossDesk repo - uses: actions/checkout@v4 - - - name: Set version number - id: version - run: | - VERSION_NUM="${GITHUB_REF##*/}" - VERSION_NUM="${VERSION_NUM#v}" - echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_ENV - echo "VERSION_NUM=${VERSION_NUM}" >> $GITHUB_OUTPUT - - - name: Checkout Pages repo - uses: actions/checkout@v4 - with: - repository: kunkundi/kunkundi.github.io - token: ${{ secrets.GH_PAGES_PAT }} - path: pages - - - name: Update download links - run: | - cd pages - sed -E -i "s/crossdesk-win-x64-[0-9]+\.[0-9]+\.[0-9]+\.exe/crossdesk-win-x64-${VERSION_NUM}.exe/g" index.html - sed -E -i "s/crossdesk-macos-x64-[0-9]+\.[0-9]+\.[0-9]+\.pkg/crossdesk-macos-x64-${VERSION_NUM}.pkg/g" index.html - sed -E -i "s/crossdesk-macos-arm64-[0-9]+\.[0-9]+\.[0-9]+\.pkg/crossdesk-macos-arm64-${VERSION_NUM}.pkg/g" index.html - sed -E -i "s/crossdesk-linux-amd64-[0-9]+\.[0-9]+\.[0-9]+\.deb/crossdesk-linux-amd64-${VERSION_NUM}.deb/g" index.html - sed -E -i "s/crossdesk-linux-arm64-[0-9]+\.[0-9]+\.[0-9]+\.deb/crossdesk-linux-arm64-${VERSION_NUM}.deb/g" index.html - - - name: Commit & Push changes - run: | - cd pages - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add index.html - git commit -m "Update download links to v${VERSION_NUM}" || echo "No changes to commit" - git push origin main - env: - VERSION_NUM: ${{ env.VERSION_NUM }}