name: Version
on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches: [main]
workflow_dispatch:
inputs:
skip_version_bump:
description: 'Skip version bumping for testing workflow logic'
required: false
default: 'false'
type: choice
options:
- 'true'
- 'false'
jobs:
version:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
outputs:
version_changed: ${{ steps.check_version.outputs.changed }}
new_version: ${{ steps.check_version.outputs.version }}
permissions:
contents: write pull-requests: read steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
fetch-depth: 0
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Build grubble
run: cargo build --release
- name: Get version before bump
id: version_before
run: |
VERSION=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Bump version
if: github.event_name != 'workflow_dispatch' || github.event.inputs.skip_version_bump != 'true'
run: ./target/release/grubble --push --tag --release-notes
- name: Check version change
id: check_version
run: |
VERSION_AFTER=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)
VERSION_BEFORE="${{ steps.version_before.outputs.version }}"
if [ "$VERSION_AFTER" != "$VERSION_BEFORE" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "version=$VERSION_AFTER" >> $GITHUB_OUTPUT
echo "Version changed: $VERSION_BEFORE -> $VERSION_AFTER"
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "version=$VERSION_AFTER" >> $GITHUB_OUTPUT
echo "Version unchanged: $VERSION_AFTER"
fi