ci for cedar-agent #8
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 | |
timeout-minutes: 15 | |
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 update --locked | |
# run: cargo update --locked | |
# - name: Run cargo test | |
# run: cargo test | |
# - name: Run cargo build | |
# run: cargo build | |
- name: Compile and release | |
uses: rust-build/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }} | |
with: | |
RUSTTARGET: x86_64-unknown-linux-musl | |
ARCHIVE_TYPES: tar.gz | |
PRE_BUILD: "cargo test" | |
# On Release: Publish Cargo package, build and push Docker image | |
release: | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
timeout-minutes: 70 | |
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 | |
cat Cargo.toml | |
- name: Dry run cargo publish | |
run: cargo publish --dry-run --allow-dirty | |
# - name: Build & Push cedar-agent | |
# uses: docker/build-push-action@v4 | |
# with: | |
# file: Dockerfile | |
# platforms: linux/amd64,linux/arm64 | |
# push: true | |
# cache-from: type=registry,ref=permitio/cedar-agent:latest | |
# cache-to: type=inline | |
# tags: | | |
# permitio/cedar-agent:latest | |
# permitio/cedar-agent:${{ github.event.release.tag_name }} | |
# - name: Publish package to crates.io | |
# run: cargo publish --token ${CRATES_TOKEN} | |
# env: | |
# CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
# - uses: taiki-e/upload-rust-binary-action@v1 | |
# with: | |
# bin: cedar-agent-${{ github.event.release.tag_name }}.crate | |
# token: ${{ secrets.TOKEN_GITHUB }} | |