Skip to content

Commit 35ac6c3

Browse files
authored
added the automatic version update action
1 parent 39463c7 commit 35ac6c3

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

.github/workflows/publish-upon-release.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,28 @@ jobs:
1515
- name: Publish crates for llama-cpp-sys-2
1616
run: cargo publish --package llama-cpp-sys-2 --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --verbose
1717
- name: Publish crates for llama-cpp-2
18-
run: cargo publish --package llama-cpp-2 --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --verbose
18+
run: cargo publish --package llama-cpp-2 --token ${{ secrets.CARGO_REGISTRY_TOKEN }} --verbose
19+
- name: Update version in TOML files
20+
run: |
21+
# Extract the current version from the TOML file
22+
CURRENT_VERSION=$(awk -F '"' '/^version/ {print $2}' llama-cpp-2/Cargo.toml)
23+
24+
# Increment the version
25+
NEXT_VERSION=$(echo "$CURRENT_VERSION" | awk -F. -v OFS=. '{++$NF; print}')
26+
27+
# Update version in llama-cpp-sys-2 Cargo.toml
28+
sed -i "s/^version = \".*\"/version = \"$NEXT_VERSION\"/g" llama-cpp-sys-2/Cargo.toml
29+
30+
# Update version in llama-cpp-2 Cargo.toml
31+
sed -i "s/^version = \".*\"/version = \"$NEXT_VERSION\"/g" llama-cpp-2/Cargo.toml
32+
sed -i "s/^\(llama-cpp-sys-2 = { path = \"\.\.\/llama-cpp-sys-2\", version = \)\"$CURRENT_VERSION\"/\1\"$NEXT_VERSION\"/" llama-cpp-2/Cargo.toml
33+
34+
35+
# Commit the changes
36+
git config --global user.email "[email protected]"
37+
git config --global user.name "GitHub Actions"
38+
git add llama-cpp-sys-2/Cargo.toml llama-cpp-2/Cargo.toml
39+
git commit -m "Bump version to $NEXT_VERSION [skip ci]"
40+
41+
# Push the changes back to the repository
42+
git push origin main:$GITHUB_REF

0 commit comments

Comments
 (0)