diff --git a/.github/workflows/qcom-promote-upstream-reusable-workflow.yml b/.github/workflows/qcom-promote-upstream-reusable-workflow.yml index be0773b..0e9f365 100644 --- a/.github/workflows/qcom-promote-upstream-reusable-workflow.yml +++ b/.github/workflows/qcom-promote-upstream-reusable-workflow.yml @@ -15,6 +15,12 @@ on: type: string required: true + debian-branch: + description: The debian branch to apply the promotion to. For example branch "debian/qcom-next" + type: string + required: false + default: debian/qcom-next + upstream-tag: description: The tag in the upstream repo to promote to. type: string @@ -25,11 +31,6 @@ on: type: string required: true - promote-changelog: - description: Run the gbp dch command to promote changelog version - type: boolean - default: false - secrets: TOKEN: required: true @@ -96,12 +97,12 @@ jobs: git branch git tag - git checkout debian/latest + git checkout ${{inputs.debian-branch}} echo "Listing all the current tags :" git tag --list if git ls-remote --exit-code --heads origin upstream/latest; then git checkout upstream/latest # Checkout this branch just to make sure it exists locally after its been fetched as gbp will need it later - git checkout - # Then revert back to debian/latest branch as we will need to have it checked out for gbp later + git checkout - # Then revert back to the inputs.debian-branch branch as we will need to have it checked out for gbp later fi @@ -201,7 +202,7 @@ jobs: git config user.name "${{vars.DEB_PKG_BOT_CI_NAME}}" git config user.email "${{vars.DEB_PKG_BOT_CI_EMAIL}}" - git checkout debian/latest + git checkout ${{inputs.debian-branch}} git checkout -b debian/pr/${{env.NORMALIZED_VERSION}}-1 diff --git a/.github/workflows/qcom-release-reusable-workflow.yml b/.github/workflows/qcom-release-reusable-workflow.yml index 5ab7dc3..7769ec4 100644 --- a/.github/workflows/qcom-release-reusable-workflow.yml +++ b/.github/workflows/qcom-release-reusable-workflow.yml @@ -127,45 +127,58 @@ jobs: cd package-repo - # 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) + NEAREST_UPSTREAM_BRANCH_TAG=$(git describe --tags --match 'upstream/*' --abbrev=0) + NEAREST_UPSTREAM_COMMIT=$(git rev-list -n 1 "$NEAREST_UPSTREAM_BRANCH_TAG") + NEAREST_UPSTREAM_TAG=$(git ls-remote --tags "https://github.com/${{vars.UPSTREAM_REPO_GITHUB_NAME}}.git" | \ + awk -v commit="$NEAREST_UPSTREAM_COMMIT" '$1 == commit && $2 ~ /refs\/tags\// { sub("refs/tags/", "", $2); print $2 }' | head -n1) + + # Now, translate the upstream/* tag to the upstream tag it represents in the upstream repo - # 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) - - # 1) Collect all binary package names from debian/control + + SOURCE=$(grep-dctrl -n -s Source -r '' debian/control | head -n1) + + # Collect all binary package names from debian/control ALL_PKGS=$(grep-dctrl -n -s Package -r '' debian/control | sort -u) - # 2) Collect dev packages (Section: libdevel) + # 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) + # 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 + #src_repo : The upstream source repository name in github format (user/repo) + #src_repo_tag : The tag in the upstream source repository that was used in the last promotion (e.g. v1.2.3) + #src_repo_commit : The commit hash in the upstream source repository that corresponds to the src_repo_tag + + #pkg_repo : The packaging repository name in github format (user/repo) + #pkg_repo_tag : The tag in the packaging repository that corresponds to this release (e.g. debian/1.2.3-1) + #pkg_repo_commit : The commit hash in the packaging repository that corresponds to the pkg_repo_tag + #pkg_repo_upstream_tag : The upstream/* tag in the packaging repository that was used for this release (e.g. upstream/v1.2.3). 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")" + $SOURCE : { + "src_repo": "${{vars.UPSTREAM_REPO_GITHUB_NAME}}", + "src_repo_tag": "$NEAREST_UPSTREAM_TAG", + "src_repo_commit": "$NEAREST_UPSTREAM_COMMIT", + + "pkg_repo": "${{ github.repository }}", + "pkg_repo_tag": "$PACKAGE_REPO_TAG", + "pkg_repo_commit": "$(git rev-parse HEAD)", + "pkg_repo_upstream_tag": "$NEAREST_UPSTREAM_BRANCH_TAG", + + "packages": $MAIN_PKGS_JSON, + "dev-packages": $DEV_PKGS_JSON, + + "build_timestamp": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" + } } EOF @@ -240,6 +253,10 @@ jobs: CATEGORY_FOLDER="${{ inputs.test-run == true && 'test' || 'proposed'}}" SUITE_NAME="${{ inputs.distro-codename }}" VERSION_NAME="${{ needs.pkg-release.outputs.complete_version }}" + WORKFLOW_BUILD_ID="${{ github.run_id }}" + WORKFLOW_RUN_ID="${{ github.run_attempt }}" + + S3_BUCKET_PATH="${OWNER_NAME}/pkg/${CATEGORY_FOLDER}/${WORKFLOW_BUILD_ID}/${WORKFLOW_RUN_ID}/${REPO_NAME}/${SUITE_NAME}/${VERSION_NAME}/" echo "ORG_NAME=${OWNER_NAME}" echo "REPO_NAME=${REPO_NAME}" @@ -247,7 +264,9 @@ jobs: 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 + echo "S3 Bucket Path: ${S3_BUCKET_PATH}" + + echo "S3_BUCKET_PATH=${S3_BUCKET_PATH}" >> $GITHUB_ENV - name: Upload released debian package to S3 uses: qualcomm-linux/upload-private-artifact-action@aws