-
Notifications
You must be signed in to change notification settings - Fork 56
42 lines (33 loc) · 1.54 KB
/
publish-upon-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
name: Test Publish to Crates.io
on:
release:
types:
- created
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: RUST_BACKTRACE=1 Publish crates for llama-cpp-sys-2
run: cargo publish --package llama-cpp-sys-2 --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --verbose --dry-run
- name: Publish crates for llama-cpp-2
run: RUST_BACKTRACE=1 cargo publish --package llama-cpp-2 --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --verbose --dry-run
- name: Update version in TOML files
run: |
RUST_BACKTRACE=1
# Extract the current version from the TOML file
CURRENT_VERSION=$(awk -F '"' '/^version/ {print $2}' llama-cpp-2/Cargo.toml)
# Increment the version
NEXT_VERSION=$(echo "$CURRENT_VERSION" | awk -F. -v OFS=. '{++$NF; print}')
# Update version in llama-cpp-sys-2 Cargo.toml
sed -i "s/^version = \".*\"/version = \"$NEXT_VERSION\"/g" llama-cpp-sys-2/Cargo.toml
# Update version in llama-cpp-2 Cargo.toml
sed -i "s/^version = \".*\"/version = \"$NEXT_VERSION\"/g" llama-cpp-2/Cargo.toml
# Commit the changes
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add llama-cpp-sys-2/Cargo.toml llama-cpp-2/Cargo.toml
git commit -m "Bump version to $NEXT_VERSION [skip ci]"
# Push the changes back to the repository
git push origin main:$GITHUB_REF