-
Notifications
You must be signed in to change notification settings - Fork 12
103 lines (84 loc) · 2.79 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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 }}