Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: PR Checks

on:
pull_request:
branches: [ main ]
push:
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read
pull-requests: write
issues: write

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
# Quick checks that fail fast
format:
name: Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: Check formatting
run: cargo fmt --all -- --check

lint:
name: Clippy Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry/index
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-registry-

- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-build-

- name: Run Clippy
run: make ci-lint

# Main test suite
test:
name: Test Suite
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
rust: [stable, beta]
exclude:
- os: macos-latest
rust: beta

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry/index
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.rust }}-cargo-registry-

- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-${{ matrix.rust }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.rust }}-cargo-build-

- name: Generate test certificates
run: |
mkdir -p certs
openssl req -x509 -newkey rsa:4096 -keyout certs/test_key.pem -out certs/test_cert.pem -days 365 -nodes -subj "/CN=localhost"

- name: Run tests
run: make ci-test

- name: Run doctests
run: cargo test --doc

# Security audit
security:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install cargo-audit
run: cargo install cargo-audit

- name: Run security audit
run: make ci-security


# Summary job that depends on all checks
pr-checks-complete:
name: All PR Checks Passed
runs-on: ubuntu-latest
needs: [format, lint, test, security]
if: always()
steps:
- name: Check results
run: |
if [[ "${{ needs.format.result }}" == "failure" ]] || \
[[ "${{ needs.lint.result }}" == "failure" ]] || \
[[ "${{ needs.test.result }}" == "failure" ]] || \
[[ "${{ needs.security.result }}" == "failure" ]]; then
echo "❌ One or more checks failed"
exit 1
fi
echo "✅ All PR checks passed!"
246 changes: 246 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
name: Release

on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-*'
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 0.2.0)'
required: true
type: string
dry_run:
description: 'Perform dry run only (do not publish)'
required: false
type: boolean
default: false

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
# Pre-release validation
validate:
name: Pre-release Validation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry/index
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-registry-

- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-release-

- name: Run tests
run: cargo test --all-features

- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Check formatting
run: cargo fmt --all -- --check

- name: Build documentation
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: -D warnings

- name: Verify package can be built
run: cargo package --allow-dirty

- name: Verify version matches
if: github.event_name == 'push'
run: |
CARGO_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[0].version')
RELEASE_TAG="${GITHUB_REF#refs/tags/}"

echo "Cargo.toml version: $CARGO_VERSION"
echo "Git tag: $RELEASE_TAG"

if [ "$CARGO_VERSION" != "$RELEASE_TAG" ]; then
echo "❌ Error: Version mismatch!"
echo "Cargo.toml version ($CARGO_VERSION) does not match git tag ($RELEASE_TAG)"
echo ""
echo "To fix this:"
echo "1. Update version in Cargo.toml to $RELEASE_TAG"
echo "2. Commit the change"
echo "3. Re-tag with: git tag -f $RELEASE_TAG"
exit 1
fi

echo "✅ Version check passed"

# Publish to crates.io
publish:
name: Publish to crates.io
needs: validate
runs-on: ubuntu-latest
if: |
github.event_name == 'push' ||
(github.event_name == 'workflow_dispatch' && !inputs.dry_run)
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry/index
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-registry-

- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

- name: Create publish summary
run: |
VERSION="${GITHUB_REF#refs/tags/}"

echo "## 🚀 Published to crates.io" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version ${VERSION}** has been successfully published!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`toml" >> $GITHUB_STEP_SUMMARY
echo "[dependencies]" >> $GITHUB_STEP_SUMMARY
echo "github_app = \"${VERSION}\"" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Links" >> $GITHUB_STEP_SUMMARY
echo "- 📦 [crates.io/crates/github_app](https://crates.io/crates/github_app)" >> $GITHUB_STEP_SUMMARY
echo "- 📚 [docs.rs/github_app/${VERSION}](https://docs.rs/github_app/${VERSION})" >> $GITHUB_STEP_SUMMARY

# Dry run for testing
dry-run:
name: Publish Dry Run
needs: validate
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && inputs.dry_run
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry/index
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-registry-

- name: Run dry-run publish
run: cargo publish --dry-run --allow-dirty

- name: Display package contents
run: |
echo "## 📦 Package Contents" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
cargo package --list --allow-dirty >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

# Update documentation
update-docs:
name: Update Documentation
needs: publish
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Documentation summary
run: |
VERSION="${GITHUB_REF#refs/tags/}"

echo "## 📚 Documentation Updated" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Documentation for version ${VERSION} is being built on docs.rs." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "It should be available at https://docs.rs/github_app/${VERSION} within a few minutes." >> $GITHUB_STEP_SUMMARY

# Post-release checks
verify-published:
name: Verify Published Package
needs: publish
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Wait for crates.io to sync
run: sleep 60

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Verify package is available
run: |
VERSION="${GITHUB_REF#refs/tags/}"

echo "Checking if github_app ${VERSION} is available on crates.io..."

# Try to fetch the package info
if cargo search github_app --limit 10 | grep -q "github_app.*${VERSION}"; then
echo "✅ Package successfully published and indexed on crates.io!"
else
echo "⚠️ Package may still be indexing. Please check manually."
fi

- name: Test installation
run: |
VERSION="${GITHUB_REF#refs/tags/}"

# Create a test project and try to install the new version
cargo init --lib test-install
cd test-install
cargo add github_app@${VERSION} || echo "Package may still be syncing"

# Announce release
announce:
name: Announce Release
needs: [publish, verify-published]
runs-on: ubuntu-latest
if: github.event_name == 'push' && success()
steps:
- name: Create release summary
run: |
VERSION="${GITHUB_REF#refs/tags/}"

echo "## 🎉 Release ${VERSION} Complete!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### ✅ Published Successfully" >> $GITHUB_STEP_SUMMARY
echo "- 📦 [crates.io/crates/github_app](https://crates.io/crates/github_app)" >> $GITHUB_STEP_SUMMARY
echo "- 📚 [docs.rs/github_app/${VERSION}](https://docs.rs/github_app/${VERSION})" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`toml" >> $GITHUB_STEP_SUMMARY
echo "[dependencies]" >> $GITHUB_STEP_SUMMARY
echo "github_app = \"${VERSION}\"" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### What's Next?" >> $GITHUB_STEP_SUMMARY
echo "- Documentation will be available on docs.rs within a few minutes" >> $GITHUB_STEP_SUMMARY
echo "- All CI checks passed ✅" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Thank you for using github_app! 🚀" >> $GITHUB_STEP_SUMMARY
Loading