Skip to content

Bump Version

Bump Version #8

Workflow file for this run

name: Bump Version
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
bump-version:
runs-on: ubuntu-latest
name: Bump Version and Create PR
steps:
- uses: actions/checkout@v4
- name: Set up Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Fetch all tags and branches
run: git fetch --tags --prune
- name: Get latest tag
id: get_latest_tag
run: |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
- name: Extract version from tag
id: extract_version
run: |
version=$(echo "${{ env.latest_tag }}" | sed 's/^v//')
echo "version=$version" >> $GITHUB_ENV
- name: Delete remote branch if exists
run: |
branch=bump-version-${{ env.version }}
if git ls-remote --exit-code --heads origin $branch; then
git push origin --delete $branch
fi
- name: Update Cargo.toml version
run: |
VERSION=${{ env.version }}
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" Cargo.toml
cat Cargo.toml
- name: Validate Cargo.toml
run: cargo check
- name: Commit changes
if: ${{ success() }}
run: |
git switch -c bump-version-${{ env.version }}
git add Cargo.toml
git commit -m "Set version to ${{ env.version }}"
git push origin bump-version-${{ env.version }}
- name: Install GitHub CLI
run: sudo apt-get install -y gh
- name: Create Pull Request
if: ${{ success() }}
run: |
source_branch=bump-version-${{ env.version }}
base_branch=main
title="Bump Version v${{ env.version }}"
description="Auto-generated PR to bump version of Cargo.toml"
gh pr create -B "$base_branch" -H "$source_branch" --title "$title" --body "$description"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}