ci for cedar-agent #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cedar-agent and Docker Build | |
on: | |
pull_request: | |
branches: | |
- main | |
release: | |
types: [published] | |
jobs: | |
# On PR: Run Cargo tests, build, and update | |
pr_checks: | |
#if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: Run cargo test | |
run: cargo test | |
- name: Run cargo build | |
run: cargo build | |
- name: Run cargo update | |
run: cargo update | |
#cargo generate-lockfile | |
#cargo update --offline | |
#cargo update --locked | |
# On Release: Publish Cargo package, build and push Docker images | |
release: | |
#if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
- name: Update Cargo.toml version | |
run: | | |
#sed -i '/\[package\]/,/^version = /s/^version = .*/version = \"${{ github.event.release.tag_name }}\"/' Cargo.toml | |
sed -i '/\[package\]/,/^version = /s/^version = .*/version = \"1.1.1\"/' Cargo.toml | |
cat Cargo.toml | |
- name: Dry run cargo publish | |
run: cargo publish --dry-run --allow-dirty | |
# - name: Publish package to crates.io | |
# run: cargo publish | |
# env: | |
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
- name: Build & Push cedar-agent | |
uses: docker/build-push-action@v4 | |
with: | |
file: Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: false | |
cache-from: type=registry,ref=permitio/cedar-agent:latest | |
cache-to: type=inline | |
tags: | | |
permitio/cedar-agent:latest | |
permitio/cedar-agent:1.1.1 |