Files
EOS/.github/workflows/bump-version.yml
Bobby Noelte 976a2c8405
Some checks failed
Bump Version / Bump Version Workflow (push) Has been cancelled
docker-build / platform-excludes (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
chore: automate development version and release generation (#772)
This change introduces a GitHub Action to automate release creation, including
proper tagging and automatic addition of a development marker to the version.

A hash is also appended to development versions to make their state easier to
distinguish.

Tests and release documentation have been updated to reflect the revised
release workflow. Several files now retrieve the current version dynamically.

The test --full-run option has been rename to --finalize to make
clear it is to do commit finalization testing.

Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
2025-11-20 00:10:19 +01:00

100 lines
3.3 KiB
YAML

name: Bump Version
# Trigger the workflow on any push to main
on:
push:
branches:
- main
jobs:
bump-version:
runs-on: ubuntu-latest
name: Bump Version Workflow
steps:
# --- Step 1: Checkout the repository ---
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed to create tags and see full history
persist-credentials: true # Needed for pushing commits and tags
# --- Step 2: Set up Python ---
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
# --- Step 3: Calculate version dynamically ---
- name: Calculate version
id: calc
run: |
# Call custom version calculation script
VERSION=$(python scripts/get_version.py)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Computed version: $VERSION"
# --- Step 4: Skip workflow for development versions ---
- name: Skip if version contains 'dev'
run: |
# Exit workflow early if the version contains 'dev'
if [[ "${{ steps.calc.outputs.version }}" == *dev* ]]; then
echo "Version contains 'dev', skipping bump version workflow."
exit 0
fi
# --- Step 5: Update files and commit if necessary ---
- name: Update files and commit
run: |
# Define files to update
UPDATE_FILES="haaddon/config.yaml"
# Call general Python version replacement script
python scripts/update_version.py "${{ steps.calc.outputs.version }}" $UPDATE_FILES
# Commit changes if any
git config user.name "github-actions"
git config user.email "actions@github.com"
git add $UPDATE_FILES
if git diff --cached --quiet; then
echo "No files changed. Skipping commit."
else
git commit -m "chore: bump version to ${{ steps.calc.outputs.version }}"
git push
# --- Step 6: Create release tag ---
- name: Create release tag if it does not exist
id: tagging
run: |
TAG="v${{ steps.calc.outputs.version }}"
if git rev-parse --verify "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists. Skipping tag creation."
echo "created=false" >> $GITHUB_OUTPUT
else
git tag -a "v${{ steps.calc.outputs.version }}" -m "Release ${{ steps.calc.outputs.version }}"
git push origin "v${{ steps.calc.outputs.version }}"
echo "created=true" >> $GITHUB_OUTPUT
fi
# --- Step 7: Bump to development version ---
- name: Bump dev version
id: bump_dev
run: |
VERSION_BASE=$(python scripts/bump_dev_version.py | tail -n1)
if [ -z "$VERSION_BASE" ]; then
echo "Error: bump_dev_version.py returned an empty version."
exit 1
fi
echo "version_base=$VERSION_BASE" >> $GITHUB_OUTPUT
git config user.name "github-actions"
git config user.email "actions@github.com"
git add src/akkudoktoreos/core/version.py
if git diff --cached --quiet; then
echo "version.py not changed. Skipping commit."
else
git commit -m "chore: bump dev version to ${VERSION_BASE}"
git push