name: CI # Runners: uvacompute (https://uvacompute.com) # To enable, set the UVA_RUNNER repo variable to the correct runner label. # runs-on: ${{ vars.UVA_RUNNER || 'ubuntu-latest' }} on: push: branches: [main] workflow_dispatch: permissions: contents: write packages: write jobs: cargo: name: Cargo Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: components: clippy - uses: Swatinem/rust-cache@v2 - name: Install system dependencies run: sudo apt-get update && sudo apt-get install -y libx11-dev libxtst-dev - name: Clippy run: cargo clippy -- -D warnings - name: Build run: cargo build --release --locked - uses: actions/upload-artifact@v4 with: name: deskctl-linux-x86_64 path: target/release/deskctl retention-days: 7 docker: name: Docker Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Get version id: version run: echo "version=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')" >> "$GITHUB_OUTPUT" - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - uses: docker/build-push-action@v6 with: context: . file: docker/Dockerfile push: true tags: | ghcr.io/${{ github.repository }}:latest ghcr.io/${{ github.repository }}:v${{ steps.version.outputs.version }} cache-from: type=gha cache-to: type=gha,mode=max release: name: Release needs: [cargo, docker] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Get version id: version run: echo "version=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')" >> "$GITHUB_OUTPUT" - uses: actions/download-artifact@v4 with: name: deskctl-linux-x86_64 path: artifacts/ - name: Prepare release assets run: | chmod +x artifacts/deskctl mv artifacts/deskctl artifacts/deskctl-linux-x86_64 - name: Create or update release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | TAG="v${{ steps.version.outputs.version }}" IMAGE="ghcr.io/${{ github.repository }}:${TAG}" BODY="## Artifacts - **Binary:** \`deskctl-linux-x86_64\` (attached) - **Docker:** \`docker pull ${IMAGE}\`" if gh release view "$TAG" &>/dev/null; then gh release upload "$TAG" artifacts/deskctl-linux-x86_64 --clobber else gh release create "$TAG" \ --title "$TAG" \ --notes "${BODY}" \ artifacts/deskctl-linux-x86_64 fi