diff --git a/.github/actions/build_package/action.yml b/.github/actions/build_package/action.yml index 9652036..06630ff 100644 --- a/.github/actions/build_package/action.yml +++ b/.github/actions/build_package/action.yml @@ -44,7 +44,7 @@ runs: run: | echo "Listing the content of the workspace :"; tree - mkdir ${{inputs.build-dir}} + mkdir -p ${{inputs.build-dir}} if grep -q 'quilt' ./package-repo/debian/source/format; then echo "Source format is quilt" diff --git a/.github/workflows/qcom-build-pkg-reusable-workflow.yml b/.github/workflows/qcom-build-pkg-reusable-workflow.yml index 73e3b1a..74e148b 100644 --- a/.github/workflows/qcom-build-pkg-reusable-workflow.yml +++ b/.github/workflows/qcom-build-pkg-reusable-workflow.yml @@ -33,11 +33,6 @@ on: type: boolean default: false - push-to-repo: - description: Whether or not to push the built package to the repository if the compiled version is not already in it - type: boolean - default: false - is-post-merge: description: true if this build has been triggered by a merge into debian/latest. Will ensure PR branch is deleted type: boolean @@ -55,7 +50,6 @@ on: permissions: contents: read - security-events: write env: REPO_URL: https://qualcomm-linux.github.io/pkg-oss-staging-repo/ @@ -115,7 +109,7 @@ jobs: distro-codename: ${{inputs.distro-codename}} - name: Push package to repo - if: ${{inputs.push-to-repo == true}} + if: ${{inputs.is-post-merge == true}} uses: ./qcom-build-utils/.github/actions/push_to_repo with: distro-codename: ${{inputs.distro-codename}} diff --git a/.github/workflows/qcom-promote-upstream-reusable-workflow.yml b/.github/workflows/qcom-promote-upstream-reusable-workflow.yml index 419b66d..be0773b 100644 --- a/.github/workflows/qcom-promote-upstream-reusable-workflow.yml +++ b/.github/workflows/qcom-promote-upstream-reusable-workflow.yml @@ -41,8 +41,7 @@ env: NORMALIZED_VERSION: "" DISTRIBUTION: noble - #TODO : Check if a PR branch already exist. This would mean that someone or something triggered the - # promotion more than once before it was merged + UPSTREAM_TAG_ALREADY_EXISTS: false jobs: promote-upstream-version: @@ -61,25 +60,22 @@ jobs: steps: - - name: Ensure Workspace Is Clean - run: rm -rf * - # Normalizing a tag : (e.g ) v1.0.0 -> 1.0.0 - name: Normalize Tag Version run: | - echo "ℹ️Input upstream-tag is : ${{inputs.upstream-tag}}" + echo "ℹ️ Input upstream-tag is : ${{inputs.upstream-tag}}" NORMALIZED_VERSION=$(echo "${{inputs.upstream-tag}}" | sed 's/^v//') echo "NORMALIZED_VERSION=$NORMALIZED_VERSION" >> $GITHUB_ENV - echo "ℹ️Normalized version : $NORMALIZED_VERSION" + echo "ℹ️ Normalized version : $NORMALIZED_VERSION" - name: Checkout qcom-build-utils uses: actions/checkout@v4 with: repository: qualcomm-linux/qcom-build-utils ref: ${{inputs.qcom-build-utils-ref}} - token: ${{secrets.TOKEN}} + #token: Not needed for public repo path: ./qcom-build-utils fetch-depth: 1 sparse-checkout: | @@ -90,7 +86,6 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: - clean: false # A rm -rf * was done first, don't clean otherwise this would delete qcom-build-utils cloned above token: ${{secrets.TOKEN}} path: ./package-repo fetch-depth: 0 @@ -119,16 +114,54 @@ jobs: exit 1 fi - - name: Determine If Requested Tag Already Exist In upstream/ + - name: Validate the upstream tag promotion state run: | cd ./package-repo - if (git tag --list | grep "upstream/${{env.NORMALIZED_VERSION}}"); then - echo "❌ It appears like this repo has already integrated the upstream tag '${{inputs.upstream-tag}}'" \ - " because a local tag 'upstream/$NORMALIZED_VERSION' already exists." + # Check if the upstream/ tag does not already exists + if ! git tag --list | grep "upstream/${{env.NORMALIZED_VERSION}}"; then + echo "✅ The upstream tag '${{inputs.upstream-tag}}' has not been promoted yet. Continuing." + exit 0 + fi + + echo "⚠️ It appears like this repo has already integrated the upstream tag '${{inputs.upstream-tag}}'" + + LATEST_UPSTREAM_TAG=$(git tag --list 'upstream/*' | sort -V | tail -1) + + echo "ℹ️ The latest upstream tag in the repo is: $LATEST_UPSTREAM_TAG" + + if [ "$LATEST_UPSTREAM_TAG" != "upstream/${{env.NORMALIZED_VERSION}}" ]; then + echo "❌ However, the existing tag 'upstream/${{env.NORMALIZED_VERSION}}' is NOT the latest upstream tag" + echo "❌ This means we are trying to promote an older tag. Aborting." + exit 1 + fi + + echo "ℹ️ The existing tag 'upstream/${{env.NORMALIZED_VERSION}}' is the latest upstream tag already." + echo "ℹ️ This is likely a second attempt to promote the same upstream tag, where the first attempt already added the upstream tag in the upstram branch" + + # Check if there is a PR open for this already + gh auth login --with-token <<< "${{secrets.TOKEN}}" + PRS=$(gh pr list --head "debian/pr/${{env.NORMALIZED_VERSION}}-1" --state open --json number --jq '.[].number') + if [ -n "$PRS" ]; then + echo "❌ An open PR already exists for this promotion attempt: $PRS" + echo "❌ Please merge or close the existing PR before attempting to promote the same upstream tag again." + exit 1 + fi + + # If we reach this point, it means the upstream tag exists but no PR is open for it + echo "⚠️ The upstream tag 'upstream/${{env.NORMALIZED_VERSION}}' already exists but no PR is open for it." + echo "⚠️ This likely means the previous promotion PR was closed without merging." + echo "⚠️ We will proceed with the promotion, but please ensure to merge the resulting PR to avoid confusion like this." + + # Keep track that the upstream tag already exists + echo "UPSTREAM_TAG_ALREADY_EXISTS=true" >> $GITHUB_ENV + + # Perform a last check to see if the debian/pr/-1 branch already exists locally (which would mean its also present remotely) + if git ls-remote --exit-code --heads origin "debian/pr/${{env.NORMALIZED_VERSION}}-1"; then + echo "❌ The debian/pr/${{env.NORMALIZED_VERSION}}-1 branch already exists remotely." + echo "❌ This likely means the previous promotion PR branch was not deleted after closing the PR." + echo "❌ Please delete the remote branch before attempting to promote the same upstream tag again." exit 1 - else - echo "✅ TODO MAKE SURE WE ARE NOT REGRESSING" fi - name: Add Upstream Link As A Remote And Fetch Tags @@ -137,6 +170,15 @@ jobs: git remote add upstream-source https://x-access-token:${{secrets.TOKEN}}@github.com/${{inputs.upstream-repo}}.git git fetch upstream-source "+refs/tags/*:refs/tags/*" + - name: Ensure the tag exists in the upstream repo + run: | + cd ./package-repo + + if ! git rev-parse --verify "refs/tags/${{inputs.upstream-tag}}" >/dev/null 2>&1; then + echo "❌ The specified upstream tag '${{inputs.upstream-tag}}' does not exist in the upstream repository." + exit 1 + fi + - name: Pre-populate the upstream/latest branch if first promotion run: | cd ./package-repo @@ -184,13 +226,17 @@ jobs: run: | cd ./package-repo - # Push upstream/latest branch promoted to the tag - git push origin upstream/latest + if [ "${{env.UPSTREAM_TAG_ALREADY_EXISTS}}" = "false" ]; then + # This is the happy path where no previous promotion attempt was detected - git tag upstream/${{env.NORMALIZED_VERSION}} upstream/latest + # Push upstream/latest branch promoted to the tag + git push origin upstream/latest - # Push that new tag - git push origin upstream/${{env.NORMALIZED_VERSION}} + git tag upstream/${{env.NORMALIZED_VERSION}} upstream/latest + + # Push that new tag + git push origin upstream/${{env.NORMALIZED_VERSION}} + fi git push origin debian/pr/${{env.NORMALIZED_VERSION}}-1 @@ -200,44 +246,6 @@ jobs: gh auth login --with-token <<< "${{secrets.TOKEN}}" - gh pr create \ - --title "Promote upstream version ${{env.NORMALIZED_VERSION}}" \ - --body "Automated PR to test upstream version promotion. Checkout this branch locally and push additional commits to make the build pass if need be. - \`\`\`mermaid - --- - config: - themeVariables: - 'gitInv2': '#ff0000' - gitGraph: - parallelCommits: true - rotateCommitLabel: true - --- - gitGraph BT: - - branch debian/latest order: 1 - branch upstream-main order: 4 - branch upstream/latest order: 3 - checkout main - commit id: 'Unrelated history: workflows, doc' - checkout upstream-main - commit - checkout upstream-main - commit - commit id: 'release' tag: 'v1.0.0' - checkout upstream/latest - commit id: 'previous stuff' - merge upstream-main id: 'Filtered .github/debian folders' tag: 'upstream/1.0.0' - checkout debian/latest - commit - commit - commit - branch debian/pr/1.0.0-1 order: 2 - merge upstream/latest id: '*YOU ARE HERE*' type: HIGHLIGHT - commit id: 'possible patches' - checkout debian/latest - merge debian/pr/1.0.0-1 id: 'USER CLICKED MERGE' - commit id: 'suite: UNRELEASED to unstable' type: HIGHLIGHT tag: 'debian/1.0.0-1' - commit id: 'suite: unstable->UNRELEASED' - \`\`\` " \ - --base debian/latest \ - --head debian/pr/${{env.NORMALIZED_VERSION}}-1 + ../qcom-build-utils/scripts/create_promotion_pr.py \ + --upstream-tag "${{inputs.upstream-tag}}" \ + --normalized-version "${{env.NORMALIZED_VERSION}}" diff --git a/.github/workflows/qcom-release-reusable-workflow.yml b/.github/workflows/qcom-release-reusable-workflow.yml index 0fe1417..5ab7dc3 100644 --- a/.github/workflows/qcom-release-reusable-workflow.yml +++ b/.github/workflows/qcom-release-reusable-workflow.yml @@ -1,6 +1,10 @@ name: Release Promotion Workflow description: | - This reusable workflow is called by a user to create a release of the package + This reusable workflow is called by a user to create a release of the package. A release is the act of changing + the latest changelog entry's 'suite' from UNRELEASED to unstable, building the package, committing the changelog change, + tagging the release commit, and bumping the changelog for the next development cycle. + At last, the built package is uploaded to a private S3 bucket for later retrieval. Included alongside the built package + is a provenance file containing metadata about the source and package repositories and commits. on: workflow_call: @@ -15,44 +19,83 @@ on: type: string default: noble + test-run: + description: true if this is a test run. Packages will be uploaded in test folder in S3 + type: boolean + default: true + + runner: + description: The runner to use for the build + type: string + default: ubuntu-latest + secrets: TOKEN: required: true permissions: contents: read - security-events: write jobs: pkg-release: - runs-on: ubuntu-latest + runs-on: ${{inputs.runner}} + + outputs: + complete_version: ${{ steps.changelog.outputs.version }} defaults: run: shell: bash + container: + image: ghcr.io/qualcomm-linux/pkg-builder:${{inputs.runner == 'ubuntu-latest' && 'amd64' || 'arm64'}}-${{inputs.distro-codename}} + options: --privileged + credentials: + username: ${{vars.DEB_PKG_BOT_CI_USERNAME}} + password: ${{secrets.TOKEN}} + steps: - - name: Install devscripts - run: sudo apt update && sudo apt install -y devscripts + - name: Checkout qcom-build-utils + uses: actions/checkout@v4 + with: + repository: qualcomm-linux/qcom-build-utils + ref: ${{inputs.qcom-build-utils-ref}} + token: ${{secrets.TOKEN}} + path: ./qcom-build-utils + fetch-depth: 1 + sparse-checkout: | + .github + scripts - name: Checkout Packaging Repo uses: actions/checkout@v4 with: - clean: false token: ${{secrets.TOKEN}} path: ./package-repo fetch-depth: 0 fetch-tags: true + # Take the latest changelog entry and change the suite name from UNRELEASED to unstable and set timestamp and tag + # the debian/latest branch to debian/ where is the version from the changelog. It is conceptually + # important that the changelog entry suite is UNRELEASED at any point except in the commit that represents the release. + # The commit that represents the release is created in this step and shall only contain the changelog change from UNRELEASED to unstable. - name: Changelog suite name change + id: changelog run: | cd ./package-repo + git config user.name "${{vars.DEB_PKG_BOT_CI_NAME}}" + git config user.email "${{vars.DEB_PKG_BOT_CI_EMAIL}}" + + export DEBFULLNAME="${{vars.DEB_PKG_BOT_CI_NAME}}" + export DEBEMAIL="${{vars.DEB_PKG_BOT_CI_EMAIL}}" + git checkout debian/latest - cat debian/changelog + echo "Initial changelog content:" + cat debian/changelog | sed 's/^/\x1b[34m/' | sed 's/$/\x1b[0m/' # Check if the latest changelog entry suite is UNRELEASED if ! head -1 debian/changelog | grep -q 'UNRELEASED'; then @@ -61,26 +104,98 @@ jobs: exit 1 fi - #Update the changelog timestamp + version=$(dpkg-parsechangelog --show-field Version) + echo "version=${version}" >> $GITHUB_OUTPUT + echo "Releasing version: ${version} for suite 'unstable'" | sed 's/^/\x1b[32m/' | sed 's/$/\x1b[0m/' + + # This is the important part; change UNRELEASED to unstable and update the changelog timestamp dch --release --distribution=unstable "Release" - cat debian/changelog + echo "Updated changelog content:" + cat debian/changelog | sed 's/^/\x1b[34m/' | sed 's/$/\x1b[0m/' - - name: Commit changelog suite change + git commit -a -m "debian/changelog: Release version ${version} for suite 'unstable'" + + git tag debian/${version} + + git log --graph --oneline -n 10 --color=always + + #TODO pkg_repo_branch needs to be dynamic based on the branch used to call the workflow + - name: Create provenance file run: | - cd ./package-repo + mkdir build - git config user.name "${{vars.DEB_PKG_BOT_CI_NAME}}" - git config user.email "${{vars.DEB_PKG_BOT_CI_EMAIL}}" + cd package-repo - export DEBFULLNAME="${{vars.DEB_PKG_BOT_CI_NAME}}" - export DEBEMAIL="${{vars.DEB_PKG_BOT_CI_EMAIL}}" + # Get the nearest reachable upstream/* tag from debian/latest. + # This tag represents the source repository state that this packaging is + # intended to package. + NEAREST_UPSTREAM_TAG=$(git describe --tags --match 'upstream/*' --abbrev=0 debian/latest) - version=$(dpkg-parsechangelog --show-field Version) + # Get the commit corresponding to that tag + NEAREST_UPSTREAM_COMMIT=$(git rev-parse "$NEAREST_UPSTREAM_TAG") + + # Get the nearest reachable debian/* tag from debian/latest. + # This tag represents the packaging repository state for this release. + PACKAGE_REPO_TAG=$(git describe --tags --match 'debian/*' --abbrev=0 debian/latest) - git commit -a -m "Release version ${version}" + # 1) Collect all binary package names from debian/control + ALL_PKGS=$(grep-dctrl -n -s Package -r '' debian/control | sort -u) - git tag debian/${version} + # 2) Collect dev packages (Section: libdevel) + DEV_PKGS=$(grep-dctrl -n -F Section -e libdevel -s Package debian/control | sort -u) + + + # 3) Compute MAIN = ALL - DEV (using comm on sorted lists) + MAIN_PKGS=$(comm -23 <(printf '%s\n' "$ALL_PKGS") <(printf '%s\n' "$DEV_PKGS")) + + MAIN_PKGS_JSON=$(printf '%s\n' "$MAIN_PKGS" | jq -c -R -s 'split("\n") | map(select(length>0))') + DEV_PKGS_JSON=$(printf '%s\n' "$DEV_PKGS" | jq -c -R -s 'split("\n") | map(select(length>0))') + + # TODO + # Use tag from upstream source repo, not the upstream/* tag in the packaging repo + + cat > ../build/provenance.json << EOF + { + "src_repo": "${{vars.UPSTREAM_REPO_GITHUB_NAME}}", + "src_repo_tag": "$NEAREST_UPSTREAM_TAG", + "src_commit": "$NEAREST_UPSTREAM_COMMIT", + "pkg_repo": "${{ github.repository }}", + "pkg_repo_tag": "$PACKAGE_REPO_TAG", + "pkg_commit": "$(git rev-parse HEAD)", + "packages": $MAIN_PKGS_JSON, + "dev-packages": $DEV_PKGS_JSON, + "build_timestamp": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" + } + EOF + + echo "Content of the provenance file:" + cat ../build/provenance.json | sed 's/^/\x1b[34m/' | sed 's/$/\x1b[0m/' + + - name: Build Debian Packages + uses: ./qcom-build-utils/.github/actions/build_package + with: + distro-codename: ${{inputs.distro-codename}} + pkg-dir: package-repo + build-dir: build + + - name: Remove files with unauthorized characters + run: | + rm build/*.build + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts + path: build/ + + # After the above step that changed the changlog from UNRELEASED to unstable, now create a new changelog entry + # that bumps the version for the next development cycle and sets the suite back to UNRELEASED + - name: Commit changelog suite change + run: | + cd ./package-repo + + version=$(dpkg-parsechangelog --show-field Version) # bump Debian revision (last hyphen-separated field), e.g. 1.0.0-1 -> 1.0.0-2 if [[ "$version" != *-* ]]; then @@ -102,5 +217,41 @@ jobs: dch --newversion=${newversion} --distribution=UNRELEASED --controlmaint "Initial commit" git commit -a -m "Initial commit of new version ${newversion}" + git push origin debian/latest - git push origin debian/${version} + git push origin debian/${version} + + git log --graph --oneline -n 10 --color=always + + upload-to-s3: + needs: pkg-release + runs-on: 'lecore-prd-u2404-arm64-xlrg-od-ephem' + steps: + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts + path: build/ + + - name: Build S3 destination environment variables + run: | + OWNER_NAME="${{ github.repository_owner }}" + REPO_NAME="${{ github.event.repository.name }}" + CATEGORY_FOLDER="${{ inputs.test-run == true && 'test' || 'proposed'}}" + SUITE_NAME="${{ inputs.distro-codename }}" + VERSION_NAME="${{ needs.pkg-release.outputs.complete_version }}" + + echo "ORG_NAME=${OWNER_NAME}" + echo "REPO_NAME=${REPO_NAME}" + echo "CATEGORY_FOLDER=${CATEGORY_FOLDER}" + echo "SUITE_NAME=${SUITE_NAME}" + echo "VERSION_NAME=${VERSION_NAME}" + + echo "S3_BUCKET_PATH=${OWNER_NAME}/pkg/${CATEGORY_FOLDER}/${REPO_NAME}/${SUITE_NAME}/${VERSION_NAME}/" >> $GITHUB_ENV + + - name: Upload released debian package to S3 + uses: qualcomm-linux/upload-private-artifact-action@aws + with: + s3_bucket: qli-prd-lecore-gh-artifacts + path: build + destination: ${{ env.S3_BUCKET_PATH }} \ No newline at end of file diff --git a/.github/workflows/qcom-upstream-pr-pkg-build-reusable-workflow.yml b/.github/workflows/qcom-upstream-pr-pkg-build-reusable-workflow.yml index 263bddb..2cde0c0 100644 --- a/.github/workflows/qcom-upstream-pr-pkg-build-reusable-workflow.yml +++ b/.github/workflows/qcom-upstream-pr-pkg-build-reusable-workflow.yml @@ -50,7 +50,6 @@ on: permissions: contents: read - security-events: write env: # For ABI checker diff --git a/scripts/create_promotion_pr.py b/scripts/create_promotion_pr.py new file mode 100755 index 0000000..2b936bd --- /dev/null +++ b/scripts/create_promotion_pr.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python3 +# +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# +# SPDX-License-Identifier: BSD-3-Clause-Clear + +""" +create_promotion_pr.py + +Helper script to build a debian package using the container from the Dockerfile in the docker/ folder. +""" +import subprocess +import argparse +from color_logger import logger + +# This script is used to create the PR content of the promotion PR. Then, the actual PR is created using GitHub CLI +def parse_arguments(): + parser = argparse.ArgumentParser(description="Craft the content for a promotion PR and opoen it using GitHub CLI.") + + parser.add_argument("--upstream-tag", + required=True, + help="Upstream tag corresponding to the version being promoted.") + + parser.add_argument("--normalized-version", + required=True, + help="Normalized version of the upstream project.") + + args = parser.parse_args() + + return args + +def create_pr_title(normalized_version: str) -> str: + return f"Promotion to {normalized_version}" + +def create_pr_body(upstream_tag: str, normalized_version: str) -> str: + pr_body = f""" +# This is an automated PR to test the promotion of this package repo to the upstream project version {normalized_version}. + +This PR merges the upstream changes from the upstream tag '{upstream_tag}' into the debian/latest branch, and updated the debian/changelog version to reflect this new version. Whatever was the distro version before (the part after the '-' in a version x.y.z-a), it has been reset to -1. + +The upstream tag '{upstream_tag}' has already been merged into the upstream/latest branch, and this PR merges that branch into debian/latest. +In other words, this repo already contains the upstream changes in the upstream/latest branch, but the debian packaging is not yet updated to reflect this new upstream version. This is what this PR is doing. + +The *build-debian-package.yml* workflow is triggered automatically in this PR to test the promotion by building the Debian package with the updated upstream code and packaging. +If something breaks due to the promotion of the upstream sources to this new revision, this is the moment where you can checkout this branch locally, make changes and push additional commits to make the build pass. + +For example: you may need to add patches to the debian/patches/ folder to fix issues that were introduced upstream since the last version we were using, such as a new binary created upstream that needs to be packaged, or a build system change that requires updating the debian/rules file, etc. +Once you are satisfied with the changes, click the 'Merge' button below to finalize the promotion. + +*Note: Due to the nature of the graph that is attempted to be merged, only a merge (and therefore the creation of a merge commit) with the 'Merge' button will work.* + Attempting second option 'Squash and Merge' or 'Rebase and Merge' will fail. This is because in both of these two cases, this head branch woule need to be cleanly rebasable onto the base branch, which is not the case here. + + +This generated diagram attemps to illustrate what happened and what will happen when you click the 'Merge' button below.: + - The right most 'upstream-main' branch represents the upstream repo, where the {upstream_tag} was pulled from. + - To its left, the 'upstream/latest' branch lives is this repo, and represents a copy of the upstream repo (and it has already happened during the promotion workflow run). + The commit tagged 'upstream/{normalized_version}' is a merge from the upstream tag {upstream_tag} commit where in addition, + special git wizardry happened to perform a special filtering of any potential upstream .github/ and debian/ folders have been filtered out, + and only homonym folders from the debian/latest branch have been kept. + - To its left, this 'debian/pr/{normalized_version}-1' branch was created during the promotion workflow and is the head branch of this PR. + It represents the merge of the upstream/latest branch into debian/latest. + - Note that an extra commit for updating the debian/changelog file to reflect the new version {normalized_version}-1 has been added on top of that merge. +""" + + mermaid_diagram = f""" +```mermaid +--- +config: + themeVariables: + 'gitInv2': '#ff0000' +gitGraph: + parallelCommits: true + rotateCommitLabel: true +--- +gitGraph BT: + branch debian/latest order: 1 + branch upstream-main order: 4 + branch upstream/latest order: 3 + checkout main + commit id: 'Unrelated history: workflows, doc' + checkout upstream-main + commit + checkout upstream-main + commit + commit id: 'release' tag: '{upstream_tag}' + checkout upstream/latest + commit id: 'previous stuff' + merge upstream-main id: 'Filtered .github/debian folders' tag: 'upstream/{normalized_version}' + checkout debian/latest + commit + commit + commit + branch debian/pr/{normalized_version}-1 order: 2 + merge upstream/latest id: 'Merged Upstream' + commit id: 'Changelog version update' type: HIGHLIGHT +``` +""" + + return pr_body + mermaid_diagram + +def main(): + args = parse_arguments() + + logger.debug(f"Print of the arguments: {args}") + + pr_title = create_pr_title(args.normalized_version) + pr_body = create_pr_body(args.upstream_tag, args.normalized_version) + + # Printing the pr body in a .md file for manual review: + with open("promotion_pr_body.md", "w") as pr_body_file: + pr_body_file.write(pr_body) + + pr_creation_command = f"gh pr create --title '{pr_title}' --body-file promotion_pr_body.md --base debian/latest --head debian/pr/{args.normalized_version}-1" + + # Executing the PR creation command using GitHub CLI + subprocess.run(pr_creation_command, shell=True, check=True) + + +if __name__ == "__main__": + try: + main() + except Exception as e: + logger.critical(f"Uncaught exception : {e}") + traceback.print_exc() + sys.exit(1) diff --git a/scripts/merge_debian_packaging_upstream b/scripts/merge_debian_packaging_upstream index a71f3e5..d9c9327 100755 --- a/scripts/merge_debian_packaging_upstream +++ b/scripts/merge_debian_packaging_upstream @@ -39,7 +39,22 @@ echo "Merging upstream changes from upstream tag $upstream into Debian packaging git checkout "$upstream" git reset "$debian_ref" -- :/:debian :/:.github tree=$(git write-tree) -commit=$(git commit-tree -p "$debian_ref" -p "$upstream" -m "Packaging merge from $upstream" "$tree") + +merge_commit_header="Merge upstream tag '$upstream' into Debian packaging branch '$debian_branch'" + +merge_commit_body=$(cat <