mirror of
https://github.com/linuxserver/Heimdall.git
synced 2026-08-07 07:16:13 +00:00
Automate bumping version
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
bump:
|
||||
description: 'Version bump type'
|
||||
required: true
|
||||
default: 'patch'
|
||||
type: choice
|
||||
options:
|
||||
- patch
|
||||
- minor
|
||||
- major
|
||||
version:
|
||||
description: 'Explicit version (e.g. 2.9.0) — overrides bump type'
|
||||
required: false
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Bump version, tag and release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: 2.x
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Determine new version
|
||||
id: version
|
||||
env:
|
||||
EXPLICIT_VERSION: ${{ inputs.version }}
|
||||
BUMP: ${{ inputs.bump }}
|
||||
run: |
|
||||
current=$(sed -nE "s/^[[:space:]]*'version' => '([0-9]+\.[0-9]+\.[0-9]+)',/\1/p" config/app.php)
|
||||
if [ -z "$current" ]; then
|
||||
echo "::error::Could not read current version from config/app.php"
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "$EXPLICIT_VERSION" ]; then
|
||||
new="$EXPLICIT_VERSION"
|
||||
if ! echo "$new" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
|
||||
echo "::error::Invalid version '$new' — expected X.Y.Z"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
IFS=. read -r major minor patch <<< "$current"
|
||||
case "$BUMP" in
|
||||
major) new="$((major + 1)).0.0" ;;
|
||||
minor) new="$major.$((minor + 1)).0" ;;
|
||||
patch) new="$major.$minor.$((patch + 1))" ;;
|
||||
esac
|
||||
fi
|
||||
if git rev-parse -q --verify "refs/tags/v$new" > /dev/null; then
|
||||
echo "::error::Tag v$new already exists"
|
||||
exit 1
|
||||
fi
|
||||
echo "Bumping $current -> $new"
|
||||
echo "new=$new" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Commit bump and push tag
|
||||
env:
|
||||
NEW_VERSION: ${{ steps.version.outputs.new }}
|
||||
run: |
|
||||
sed -i -E "s/^([[:space:]]*'version' => ')[0-9.]+(',)/\1$NEW_VERSION\2/" config/app.php
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git commit -am "Bump version to $NEW_VERSION"
|
||||
git tag "v$NEW_VERSION"
|
||||
git push origin HEAD:2.x "refs/tags/v$NEW_VERSION"
|
||||
|
||||
- name: Create GitHub release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
gh release create "v${{ steps.version.outputs.new }}" \
|
||||
--title "v${{ steps.version.outputs.new }}" \
|
||||
--generate-notes
|
||||
@@ -0,0 +1,26 @@
|
||||
name: Tag version check
|
||||
|
||||
# Safety net for manually pushed tags: fails if the tag doesn't match the
|
||||
# version in config/app.php. Tags created by the Release workflow are pushed
|
||||
# with GITHUB_TOKEN and therefore don't trigger this (they always match anyway).
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Tag matches config/app.php
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Compare tag with app version
|
||||
run: |
|
||||
tag="${GITHUB_REF_NAME#v}"
|
||||
version=$(sed -nE "s/^[[:space:]]*'version' => '([0-9]+\.[0-9]+\.[0-9]+)',/\1/p" config/app.php)
|
||||
if [ "$tag" != "$version" ]; then
|
||||
echo "::error::Tag v$tag does not match config/app.php version $version — bump the version (or use the Release workflow, which does it for you)"
|
||||
exit 1
|
||||
fi
|
||||
echo "Tag v$tag matches config/app.php"
|
||||
Reference in New Issue
Block a user