From 9ad4d10bee7502243af354d2d76df4f6f758f862 Mon Sep 17 00:00:00 2001 From: Marcus Furlong Date: Wed, 6 May 2026 21:08:02 -0400 Subject: [PATCH] handle backported stable releases --- .../create-release-and-upload-assets.yml | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/create-release-and-upload-assets.yml b/.github/workflows/create-release-and-upload-assets.yml index 6090dcbf..5c440cb2 100644 --- a/.github/workflows/create-release-and-upload-assets.yml +++ b/.github/workflows/create-release-and-upload-assets.yml @@ -19,7 +19,11 @@ jobs: version: ${{ steps.set-vars.outputs.version }} rpm_version: ${{ steps.set-vars.outputs.rpm_version }} is_prerelease: ${{ steps.set-vars.outputs.is_prerelease }} + target_branch: ${{ steps.set-vars.outputs.target_branch }} steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - id: set-vars run: | if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then @@ -35,10 +39,20 @@ jobs: else IS_PRERELEASE=false fi + # Detect target branch: if tag version matches VERSION.txt, use main + # otherwise use stable-X.Y branch for backport releases + MAJOR_MINOR=$(echo "$VERSION" | grep -oP '^\d+\.\d+') + CURRENT=$(cat VERSION.txt | grep -oP '^\d+\.\d+') + if [[ "$MAJOR_MINOR" == "$CURRENT" ]]; then + TARGET_BRANCH="main" + else + TARGET_BRANCH="stable-${MAJOR_MINOR}" + fi echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "rpm_version=${RPM_VERSION}" >> $GITHUB_OUTPUT echo "is_prerelease=${IS_PRERELEASE}" >> $GITHUB_OUTPUT - echo "Version: $VERSION, RPM Version: $RPM_VERSION, Pre-release: $IS_PRERELEASE" + echo "target_branch=${TARGET_BRANCH}" >> $GITHUB_OUTPUT + echo "Version: $VERSION, RPM Version: $RPM_VERSION, Pre-release: $IS_PRERELEASE, Target: $TARGET_BRANCH" create-release: needs: setup @@ -69,7 +83,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - ref: main + ref: ${{ needs.setup.outputs.target_branch }} - name: git fetch --all run: | git fetch --all @@ -91,7 +105,7 @@ jobs: echo "${{ needs.setup.outputs.version }}" > VERSION.txt git add VERSION.txt git diff --quiet && git diff --staged --quiet || git commit -m "${COMMIT_MSG}" - git push origin main + git push origin ${{ needs.setup.outputs.target_branch }} - name: Update debian changelog env: EMAIL: furlongm@gmail.com @@ -101,7 +115,7 @@ jobs: skip-checks: true run: | gbp dch --new-version=${{ needs.setup.outputs.version }}-1 --release --distribution=stable --spawn-editor=never --commit --commit-msg="${COMMIT_MSG}" - git push origin main + git push origin ${{ needs.setup.outputs.target_branch }} build-and-upload-deb-assets: needs: [setup, create-release, update-version-and-changelog] @@ -123,8 +137,8 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - # For stable releases, use main (has updated changelog); for pre-releases, use the tag - ref: ${{ needs.setup.outputs.is_prerelease == 'false' && 'main' || github.ref }} + # For stable releases, use target branch (has updated changelog); for pre-releases, use the tag + ref: ${{ needs.setup.outputs.is_prerelease == 'false' && needs.setup.outputs.target_branch || github.ref }} - name: git fetch --all run: | git config --global --add safe.directory /__w/patchman/patchman @@ -151,7 +165,7 @@ jobs: EMAIL: furlongm@gmail.com VERSION: ${{ needs.setup.outputs.version }} run: | - # VERSION.txt and changelog already updated on main by update-version-and-changelog job + # VERSION.txt and changelog already updated on target branch by update-version-and-changelog job # Recreate tag to include those commits git tag --delete v${VERSION} git tag v${VERSION} @@ -181,7 +195,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - ref: ${{ needs.setup.outputs.is_prerelease == 'false' && 'main' || github.ref }} + ref: ${{ needs.setup.outputs.is_prerelease == 'false' && needs.setup.outputs.target_branch || github.ref }} - name: git fetch --all run: | git config --global --add safe.directory /__w/patchman/patchman