mirror of
https://github.com/linuxserver/Heimdall.git
synced 2026-08-07 07:16:13 +00:00
98 lines
3.5 KiB
YAML
98 lines
3.5 KiB
YAML
name: Release
|
|
|
|
# Stage 1 of the release flow: opens a version-bump PR against 2.x.
|
|
# When that PR is merged, tag-release.yml (stage 2) creates the tag and
|
|
# the GitHub release automatically.
|
|
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
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
release-pr:
|
|
name: Open version bump PR
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: 2.x
|
|
fetch-depth: 0
|
|
# Optional: set a RELEASE_TOKEN repo secret (fine-grained PAT with
|
|
# contents + pull-requests write) so the bump PR triggers CI checks.
|
|
# PRs created with the default github.token do not trigger workflows.
|
|
token: ${{ secrets.RELEASE_TOKEN || github.token }}
|
|
|
|
- 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: Push bump commit to release branch
|
|
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 push --force origin "HEAD:refs/heads/release/v$NEW_VERSION"
|
|
|
|
- name: Open pull request
|
|
env:
|
|
GH_TOKEN: ${{ secrets.RELEASE_TOKEN || github.token }}
|
|
NEW_VERSION: ${{ steps.version.outputs.new }}
|
|
run: |
|
|
existing=$(gh pr list --head "release/v$NEW_VERSION" --base 2.x --state open --json number -q '.[0].number')
|
|
if [ -n "$existing" ]; then
|
|
echo "PR #$existing is already open for release/v$NEW_VERSION"
|
|
else
|
|
gh pr create \
|
|
--base 2.x \
|
|
--head "release/v$NEW_VERSION" \
|
|
--title "Bump version to $NEW_VERSION" \
|
|
--body "Automated version bump. Merging this PR will tag v$NEW_VERSION and publish the GitHub release. Merge it last, once everything for the release is on 2.x."
|
|
fi
|