mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-01-10 04:36:18 +00:00
fix: bump version workflow (#824)
Skip workflow on dev version. This was not working before. Add write permission to repo. This was missing before. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
48
.github/workflows/bump-version.yml
vendored
48
.github/workflows/bump-version.yml
vendored
@@ -6,6 +6,13 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write # Required for pushing commits and tags
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: bump-version-main
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
bump-version:
|
bump-version:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -16,8 +23,7 @@ jobs:
|
|||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Needed to create tags and see full history
|
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 ---
|
# --- Step 2: Set up Python ---
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
@@ -29,70 +35,72 @@ jobs:
|
|||||||
- name: Calculate version
|
- name: Calculate version
|
||||||
id: calc
|
id: calc
|
||||||
run: |
|
run: |
|
||||||
# Call custom version calculation script
|
|
||||||
VERSION=$(python scripts/get_version.py)
|
VERSION=$(python scripts/get_version.py)
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
echo "Computed version: $VERSION"
|
echo "Computed version: $VERSION"
|
||||||
|
|
||||||
# --- Step 4: Skip workflow for development versions ---
|
# --- Step 4: Skip workflow for development versions ---
|
||||||
- name: Skip if version contains 'dev'
|
- name: Skip if version contains 'dev'
|
||||||
|
if: contains(steps.calc.outputs.version, 'dev')
|
||||||
run: |
|
run: |
|
||||||
# Exit workflow early if the version contains 'dev'
|
echo "Version contains 'dev'. Skipping release-related steps."
|
||||||
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 ---
|
# --- Step 5: Update files and commit if necessary ---
|
||||||
- name: Update files and commit
|
- name: Update files and commit
|
||||||
|
id: commit_release
|
||||||
|
if: "!contains(steps.calc.outputs.version, 'dev')"
|
||||||
run: |
|
run: |
|
||||||
# Define files to update
|
git config user.name "github-actions"
|
||||||
|
git config user.email "actions@github.com"
|
||||||
|
|
||||||
|
# Files that contain the version string
|
||||||
UPDATE_FILES="config.yaml .env"
|
UPDATE_FILES="config.yaml .env"
|
||||||
|
|
||||||
# Call general Python version replacement script
|
# Update versions
|
||||||
python scripts/update_version.py "${{ steps.calc.outputs.version }}" $UPDATE_FILES
|
python scripts/update_version.py "${{ steps.calc.outputs.version }}" $UPDATE_FILES
|
||||||
|
|
||||||
# Commit changes if any
|
# Commit changes if any
|
||||||
git config user.name "github-actions"
|
|
||||||
git config user.email "actions@github.com"
|
|
||||||
git add $UPDATE_FILES
|
git add $UPDATE_FILES
|
||||||
|
|
||||||
if git diff --cached --quiet; then
|
if git diff --cached --quiet; then
|
||||||
echo "No files changed. Skipping commit."
|
echo "No files changed. Skipping commit."
|
||||||
|
echo "committed=false" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
git commit -m "chore: bump version to ${{ steps.calc.outputs.version }}"
|
git commit -m "chore: bump version to ${{ steps.calc.outputs.version }}"
|
||||||
git push
|
git push
|
||||||
|
echo "committed=true" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- Step 6: Create release tag ---
|
# --- Step 6: Create release tag ---
|
||||||
- name: Create release tag if it does not exist
|
- name: Create release tag if it does not exist
|
||||||
id: tagging
|
id: tagging
|
||||||
|
if: steps.commit_release.outputs.committed == 'true'
|
||||||
run: |
|
run: |
|
||||||
TAG="v${{ steps.calc.outputs.version }}"
|
TAG="v${{ steps.calc.outputs.version }}"
|
||||||
|
|
||||||
if git rev-parse --verify "$TAG" >/dev/null 2>&1; then
|
if git rev-parse --verify "$TAG" >/dev/null 2>&1; then
|
||||||
echo "Tag $TAG already exists. Skipping tag creation."
|
echo "Tag $TAG already exists. Skipping tag creation."
|
||||||
echo "created=false" >> $GITHUB_OUTPUT
|
|
||||||
else
|
else
|
||||||
git tag -a "v${{ steps.calc.outputs.version }}" -m "Release ${{ steps.calc.outputs.version }}"
|
git tag -a "$TAG" -m "Release ${{ steps.calc.outputs.version }}"
|
||||||
git push origin "v${{ steps.calc.outputs.version }}"
|
git push origin "$TAG"
|
||||||
echo "created=true" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- Step 7: Bump to development version ---
|
# --- Step 7: Bump to development version ---
|
||||||
- name: Bump dev version
|
- name: Bump dev version
|
||||||
id: bump_dev
|
id: bump_dev
|
||||||
|
if: steps.commit_release.outputs.committed == 'true'
|
||||||
run: |
|
run: |
|
||||||
|
git config user.name "github-actions"
|
||||||
|
git config user.email "actions@github.com"
|
||||||
|
|
||||||
VERSION_BASE=$(python scripts/bump_dev_version.py | tail -n1)
|
VERSION_BASE=$(python scripts/bump_dev_version.py | tail -n1)
|
||||||
if [ -z "$VERSION_BASE" ]; then
|
if [ -z "$VERSION_BASE" ]; then
|
||||||
echo "Error: bump_dev_version.py returned an empty version."
|
echo "Error: bump_dev_version.py returned an empty version."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
git add src/akkudoktoreos/core/version.py
|
||||||
|
|
||||||
if git diff --cached --quiet; then
|
if git diff --cached --quiet; then
|
||||||
echo "version.py not changed. Skipping commit."
|
echo "version.py not changed. Skipping commit."
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user