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 with rustfmt and clippy run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile default echo "$HOME/.cargo/bin" >> $GITHUB_PATH $HOME/.cargo/bin/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 run: | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile default echo "$HOME/.cargo/bin" >> $GITHUB_PATH - 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"