-
Notifications
You must be signed in to change notification settings - Fork 13
146 lines (123 loc) · 4.93 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Cedar-agent cross-build and Docker Build
on: push
# release:
# types: [published]
env:
# The project name specified in Cargo.toml
PROJECT_NAME: cedar-agent
jobs:
build-cross-package:
# Set the job to run on the platform specified by the matrix below
runs-on: ${{ matrix.runner }}
# Define the build matrix for cross-compilation
strategy:
matrix:
include:
- name: linux-amd64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: linux-arm64
runner: ubuntu-latest
target: aarch64-unknown-linux-gnu
# ------- Lets keep this commented out for now for future optional use
# - name: win-amd64
# runner: windows-latest
# target: x86_64-pc-windows-msvc
# - name: macos-amd64
# runner: macos-latest
# target: x86_64-apple-darwin
# - name: macos-arm64
# runner: macos-latest
# target: aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: "${{ matrix.target }}"
- name: Setup Cache
uses: Swatinem/rust-cache@v2
- name: Update Cargo.toml version
run: |
if [[ "${{ matrix.runner }}" == "macos-latest" ]]; then
sed -i '' '/\[package\]/,/^version = /s/^version = .*/version = "${{ github.event.release.tag_name }}"/' Cargo.toml
cat Cargo.toml
fi
if [[ "${{ matrix.runner }}" == "ubuntu-latest" ]]; then
#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
fi
- name: Prepare for ARM64
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
# Define the path to the Cargo config file
CARGO_CONFIG="$HOME/.cargo/config.toml"
# Check if the file exists; if not, create it
if [[ ! -f "$CARGO_CONFIG" ]]; then
mkdir -p "$HOME/.cargo"
touch "$CARGO_CONFIG"
fi
# Add the target configuration if it doesn't already exist
if ! grep -q "\[target.aarch64-unknown-linux-gnu\]" "$CARGO_CONFIG"; then
echo -e "\n[target.aarch64-unknown-linux-gnu]" >> "$CARGO_CONFIG"
echo 'linker = "aarch64-linux-gnu-gcc"' >> "$CARGO_CONFIG"
echo "Configuration added to $CARGO_CONFIG"
else
echo "Configuration already exists in $CARGO_CONFIG"
fi
cat $HOME/.cargo/config.toml
- name: Build Binary
#if: ${{ matrix.target != 'aarch64-unknown-linux-gnu' }}
run: cargo build --verbose --release --target ${{ matrix.target }} # --locked have been removed to avoid error
# - name: Build ARM64
# if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
# uses: actions-rs/cargo@v1
# with:
# use-cross: true
# command: build
# args: --all --release --target=aarch64-unknown-linux-musl
- name: Dry run cargo publish
run: cargo publish --dry-run --allow-dirty --target ${{ matrix.target }}
- name: List files in target/release
run: |
echo "Listing files in target/release:"
ls -R target/release
# - uses: taiki-e/upload-rust-binary-action@v1
# with:
# bin: cedar-agent-${{ github.event.release.tag_name }}
# token: ${{ secrets.TOKEN_GITHUB }}
# - name: Publish package to crates.io
# run: cargo publish --token ${CRATES_TOKEN}
# env:
# CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# docker-build-push:
# runs-on: ubuntu-latest
# timeout-minutes: 70
# needs: build-cross-package
# 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: 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 }}