Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions .github/workflows/create-release-and-upload-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand 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
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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
Expand Down
Loading