Public Access
75 lines
2.0 KiB
YAML
75 lines
2.0 KiB
YAML
name: Action Gateway CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags:
|
|
- 'release/*'
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build-and-test:
|
|
name: Build & Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Install rustfmt and clippy
|
|
run: rustup component add rustfmt clippy
|
|
|
|
- name: Build
|
|
run: cargo build --release
|
|
|
|
- name: Run tests
|
|
run: cargo test
|
|
|
|
- name: Check formatting
|
|
run: cargo fmt --check
|
|
|
|
- name: Clippy
|
|
run: cargo clippy -- -D warnings
|
|
|
|
release:
|
|
name: Publish Release
|
|
runs-on: ubuntu-latest
|
|
needs: build-and-test
|
|
if: startsWith(github.ref, 'refs/tags/release/')
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust
|
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
|
with:
|
|
toolchain: stable
|
|
|
|
- name: Build release binary
|
|
run: cargo build --release
|
|
|
|
- name: Create Gitea release with binary
|
|
run: |
|
|
TAG="${GITHUB_REF#refs/tags/}"
|
|
RELEASE=$(curl -s -X POST "https://git.dominat.us/api/v1/repos/clawbot/action-gateway/releases" \
|
|
-H "Authorization: token ${{ secrets.BOT_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"tag_name\": \"$TAG\",
|
|
\"name\": \"Action Gateway $TAG\",
|
|
\"body\": \"Automated release
|
|
|
|
Commit: ${{ github.sha }}\",
|
|
\"draft\": false
|
|
}")
|
|
RELEASE_ID=$(echo "$RELEASE" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
|
|
|
curl -s -X POST "https://git.dominat.us/api/v1/repos/clawbot/action-gateway/releases/$RELEASE_ID/assets" \
|
|
-H "Authorization: token ${{ secrets.BOT_TOKEN }}" \
|
|
-F "attachment=@target/release/action-gateway;filename=action-gateway-linux-amd64"
|
|
|
|
echo "Release $TAG created: $RELEASE_ID"
|