Skip to content

Commit 47a8977

Browse files
committed
Add CI for rust crates.
1 parent cc4bf98 commit 47a8977

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

.github/workflows/release-rust.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Release Rust Crates
2+
3+
on:
4+
push:
5+
branches: [ master, develop ]
6+
paths:
7+
- 'source/ports/rs_port/Cargo.toml'
8+
- 'source/ports/rs_port/inline/Cargo.toml'
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
env:
15+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
16+
17+
jobs:
18+
release:
19+
name: Release Rust Port
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Check out the repo
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
- name: Release the port
27+
run: |
28+
cd source/ports/rs_port
29+
bash ./upload.sh

source/ports/rs_port/upload.sh

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22

33
#
44
# MetaCall Rust Port Deploy Script by Parra Studios
@@ -19,11 +19,19 @@
1919
# limitations under the License.
2020
#
2121

22-
# TODO: Automate for CD/CI
22+
function publish() {
23+
local crate_version=`cargo search --quiet $1 | grep "$1" | head -n 1 | awk '{ print $3 }'`
24+
local project_version=`cargo metadata --format-version=1 --no-deps | jq '.packages[0].version'`
25+
26+
# Check if versions do not match, and if so, publish them
27+
if [ ! "${crate_version}" = "${project_version}" ]; then
28+
echo "Publishing ${crate_version} -> ${project_version}"
29+
cargo publish --verbose --locked --token ${CARGO_REGISTRY_TOKEN}
30+
fi
31+
}
2332

2433
# Publish
25-
cargo login $TOKEN
2634
cd inline
27-
cargo publish
35+
publish metacall-inline
2836
cd ..
29-
cargo publish
37+
publish metacall

0 commit comments

Comments
 (0)