mirror of
https://github.com/harivansh-afk/deskctl.git
synced 2026-04-15 07:04:46 +00:00
ci
This commit is contained in:
parent
5d655de594
commit
01332db3bf
1 changed files with 108 additions and 0 deletions
108
.github/workflows/ci.yml
vendored
Normal file
108
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
cargo:
|
||||
name: Cargo Build
|
||||
runs-on: ${{ vars.CI_RUNNER || '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: ${{ vars.CI_RUNNER || '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
|
||||
Loading…
Add table
Add a link
Reference in a new issue