Skip to content
Merged
Show file tree
Hide file tree
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
48 changes: 44 additions & 4 deletions .github/workflows/pull-request-conditionals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ name: Filter
# This workflow is triggered on pull requests
on:
pull_request:
branches: [main]
# milestoned is added here as a workaround for release-please not triggering PR workflows (PRs should be added to a milestone to trigger the workflow).
branches:
- main
- "release/**" # milestoned is added here as a workaround for release-please not triggering PR workflows (PRs should be added to a milestone to trigger the workflow).
# labeled is added to support renovate-ready labelling on PRs
types: [milestoned, labeled, opened, reopened, synchronize]
paths-ignore:
Expand Down Expand Up @@ -87,6 +88,7 @@ jobs:
outputs:
combined: ${{ steps.combine-path-filters.outputs.combined }}
distros: ${{ steps.path-filter-iac.outputs.changes }}
run_full_tests: ${{ steps.test-routing.outputs.run_full_tests }}

steps:
- name: Checkout the code
Expand Down Expand Up @@ -131,11 +133,32 @@ jobs:
echo combined=$COMBINED >> $GITHUB_OUTPUT
echo The following packages will be triggered: $COMBINED

- name: Compute test routing
id: test-routing
run: |
BASE="${{ github.base_ref }}"
HEAD="${{ github.head_ref }}"
COMBINED='${{ steps.combine-path-filters.outputs.combined }}'

RUN_FULL=false

if [[ -n "$COMBINED" && "$COMBINED" != "[]" ]]; then
if [[ "$BASE" == "main" ]]; then
RUN_FULL=true
elif [[ "$BASE" == release/* ]]; then
if [[ "$HEAD" == release-please* ]]; then
RUN_FULL=true
fi
fi
fi

echo "run_full_tests=$RUN_FULL" >> $GITHUB_OUTPUT

# @lulaStart 11948466-9230-4498-be44-dbac784d86d1
# This job triggers a separate workflow for each changed source package, if any.
run-package-test:
needs: check-paths
if: ${{ needs.check-paths.outputs.combined != '' && needs.check-paths.outputs.combined != '[]' }}
if: ${{ needs.check-paths.outputs.run_full_tests == 'true' }}
name: Schedule
strategy:
matrix:
Expand All @@ -148,4 +171,21 @@ jobs:
flavor: ${{ matrix.flavor }}
test_type: ${{ matrix.test_type }}
secrets: inherit # Inherits all secrets from the parent workflow.
# @lulaEnd 11948466-9230-4498-be44-dbac784d86d1
# @lulaEnd 11948466-9230-4498-be44-dbac784d86d1

# Shim out required heavy tests for non-release-please PRs to release/*.
run-package-test-shim:
needs: check-paths
if: ${{ needs.check-paths.outputs.run_full_tests != 'true' }}
name: Schedule
strategy:
matrix:
package: [all]
flavor: [upstream, registry1, unicorn]
test_type: [install, upgrade]
uses: ./.github/workflows/test-shim.yaml
with:
package: ${{ matrix.package }}
flavor: ${{ matrix.flavor }}
test_type: ${{ matrix.test_type }}
secrets: inherit
99 changes: 0 additions & 99 deletions .github/workflows/pull-request-release.yaml

This file was deleted.

59 changes: 0 additions & 59 deletions .github/workflows/release-patch.yaml

This file was deleted.

10 changes: 7 additions & 3 deletions .github/workflows/tag-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
push:
branches:
- main
- "release/**"

jobs:
# @lulaStart d364a8e6-95ab-448c-bb97-9f456c85b54f
Expand All @@ -27,6 +28,9 @@ jobs:
- name: Create release tag
id: tag
uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0
with:
target-branch: ${{ github.ref_name }}
config-file: ${{ startsWith(github.ref, 'refs/heads/release/') && 'release-please-config.patch.json' || 'release-please-config.json' }}

publish-uds-core-release:
needs: tag-new-version
Expand All @@ -43,7 +47,7 @@ jobs:

scan-release:
needs: publish-uds-core-release
if: ${{ github.repository_owner == 'defenseunicorns' }}
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
contents: read
packages: read
Expand All @@ -66,8 +70,8 @@ jobs:
secrets: inherit

cut-release-branch:
needs: tag-new-version
if: ${{ needs.tag-new-version.outputs.release_created == 'true' }}
needs: publish-uds-core-release
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
78 changes: 1 addition & 77 deletions tasks/backport.yaml
Original file line number Diff line number Diff line change
@@ -1,77 +1 @@
# Copyright 2024 Defense Unicorns
# SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Defense-Unicorns-Commercial

tasks:
- name: backport
description: "Create a backport branch from release/* and cherry-pick commits"
inputs:
target_version:
description: "Target minor version (e.g., 0.54)"
commits:
description: "Comma-separated list of commit SHAs to cherry-pick, in order"
name:
description: "Optional short name to include in branch name (defaults to first SHA)"
default: ""
actions:
- description: "Create backport branch and cherry-pick commits"
shell:
darwin: bash
linux: bash
cmd: |
set -euo pipefail
CURR_BRANCH=$(git rev-parse --abbrev-ref HEAD || echo "")
# Require a clean working tree
if ! git diff-index --quiet HEAD --; then
echo "Working tree is dirty. Please commit or stash your changes before running the backport task." >&2
exit 1
fi
TV='${{ .inputs.target_version }}'
COMMITS='${{ .inputs.commits }}'
NAME_INPUT='${{ .inputs.name }}'

if [[ -z "$TV" ]]; then
echo "target_version input is required (e.g., 0.54)" >&2
exit 1
fi

RB="release/${TV}"
git fetch origin --tags
if ! git show-ref --verify --quiet "refs/remotes/origin/${RB}"; then
echo "Remote branch ${RB} not found. Ensure it exists (cut from v${TV}.0) or create it first." >&2
exit 1
fi

MINOR="$TV"

if [[ -z "$COMMITS" ]]; then
echo "No commits specified. Provide 'prs' and/or 'commits'." >&2
exit 1
fi

if [[ -z "$NAME_INPUT" ]]; then
NAME_INPUT="$(echo "$COMMITS" | cut -d',' -f1 | xargs)"
fi

BRANCH="backport/${NAME_INPUT}-to-${MINOR}"
BRANCH="${BRANCH// /-}"
BRANCH="$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]')"

echo "Creating branch: ${BRANCH} from ${RB}"
git switch -c "${BRANCH}" "origin/${RB}"

IFS=',' read -ra ARR <<< "$COMMITS"
for C in "${ARR[@]}"; do
C="$(echo "$C" | xargs)"
if [[ -n "$C" ]]; then
echo "Cherry-picking ${C}"
git cherry-pick -x "$C"
fi
done

git push -u origin "${BRANCH}"
echo "Backport branch created: ${BRANCH}"
echo "Open a PR with base=${RB} and compare=${BRANCH}"
if [[ -n "$CURR_BRANCH" ]]; then
git switch "$CURR_BRANCH"
echo "Returned to branch: $CURR_BRANCH"
fi
gh pr create --title "fix: pull in dry-er version (#113) (backport-0.58)" --body "Backport of commit: 831f8842ea53f574bb38caf68d9fa13ded63ae9c" --base "release/0.58" --head "backport/831f8842ea53f574bb38caf68d9fa13ded63ae9c-to-0.58"
Loading
Loading