Publish to Crates.io #40
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to Crates.io | |
on: | |
release: | |
types: | |
- created | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Publish crates for llama-cpp-sys-2 | |
run: RUST_BACKTRACE=1 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: Checkout main branch | |
run: git checkout main | |
- name: Update version in TOML files | |
run: | | |
# 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 | |
sed -i "s/^\(llama-cpp-sys-2 = { path = \"\.\.\/llama-cpp-sys-2\", version = \)\"$CURRENT_VERSION\"/\1\"$NEXT_VERSION\"/" llama-cpp-2/Cargo.toml | |
# Ensure that you are on the 'main' branch | |
- name: Checkout main branch | |
run: git checkout | |
# Pull the latest changes from the 'main' branch | |
- name: Pull latest changes from main | |
run: git pull origin main | |
# Commit the changes | |
- name: Commit version changes | |
run: | | |
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 | |
- name: Push changes to main | |
run: git push origin main |