diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..41a276c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,57 @@ +name: Build CrossDesk Server + +on: + push: + branches: ["**"] + tags: ["*"] + workflow_dispatch: + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Cache xmake packages + uses: actions/cache@v4 + with: + path: $HOME/.xmake/packages + key: ${{ runner.os }}-xmake-${{ hashFiles('**/xmake.lua') }} + restore-keys: | + ${{ runner.os }}-xmake- + + - name: Install xmake & deps + run: | + sudo apt update + sudo apt-get install -y software-properties-common git curl unzip build-essential + sudo add-apt-repository -y ppa:xmake-io/xmake + sudo apt update + sudo apt install -y xmake + xmake --version + + - name: Build + run: xmake b -vy crossdesk_server + + - name: Prepare dist + run: | + mkdir -p dist + cp build/linux/x86_64/release/crossdesk_server dist/ + chmod +x dist/crossdesk_server + + - name: Upload build artifact (for non-tag pushes too) + uses: actions/upload-artifact@v4 + with: + name: crossdesk_server + path: dist/crossdesk_server + + - name: Publish GitHub Release (on tag) + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v2 + with: + files: dist/crossdesk_server + generate_release_notes: true diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 2bf84a2..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Build and Deploy CrossDesk Server - -on: - push: - branches: - - "**" - tags: - - "*" - -jobs: - build: - runs-on: ubuntu-22.04 - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Cache xmake dependencies - uses: actions/cache@v4 - with: - path: /home/runner/.xmake/packages - key: ${{ runner.os }}-xmake-deps-linux-${{ hashFiles('**/xmake.lua') }} - restore-keys: | - ${{ runner.os }}-xmake-deps-linux- - - - name: Install dependencies - run: | - sudo apt update - sudo apt-get install -y software-properties-common git curl unzip build-essential - sudo add-apt-repository ppa:xmake-io/xmake - sudo apt update && sudo apt install -y xmake - - - name: Build - run: xmake b -vy crossdesk_server - - - name: Archive build artifact - run: | - tar czf crossdesk-server.tar.gz -C build/linux/x86_64/release crossdesk_server - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: crossdesk-server - path: crossdesk-server.tar.gz - - deploy: - runs-on: ubuntu-latest - needs: build - - steps: - - name: Download artifact - uses: actions/download-artifact@v4 - with: - name: crossdesk-server - path: . - - - name: Deploy to server - uses: appleboy/scp-action@v0.1.7 - with: - host: ${{ secrets.SERVER_HOST }} - username: ${{ secrets.SERVER_USER }} - key: ${{ secrets.SERVER_KEY }} # - source: "crossdesk-server.tar.gz" - target: "/home/ubuntu/deploy" - - - name: Restart service - uses: appleboy/ssh-action@v0.1.7 - with: - host: ${{ secrets.SERVER_HOST }} - username: ${{ secrets.SERVER_USER }} - key: ${{ secrets.SERVER_KEY }} - script: | - cd /home/ubuntu/deploy - tar xzf crossdesk-server.tar.gz - sudo mv crossdesk_server /usr/local/bin/crossdesk_server - sudo systemctl restart crossdesk-server