-
Notifications
You must be signed in to change notification settings - Fork 13
86 lines (71 loc) · 2.3 KB
/
build_release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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 --locked
run: 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
# - 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:${{ github.event.release.tag_name }}