From 953e0da2a3c85972aa9cfeafaff7b0c5cc68a0e9 Mon Sep 17 00:00:00 2001 From: Nicolas Schweitzer Date: Fri, 12 Jul 2024 16:14:51 +0200 Subject: [PATCH 1/5] fix(create_rc): Add git config to be able to push tag --- tasks/release.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tasks/release.py b/tasks/release.py index 50d1046f8bd4b..db4eeb1a7df6b 100644 --- a/tasks/release.py +++ b/tasks/release.py @@ -931,6 +931,11 @@ def check_for_changes(ctx, release_branch, warning_mode=False): with clone(ctx, repo_name, repo['branch'], options="--filter=blob:none --no-checkout"): # We can add the new commit now to be used by release candidate creation print(f"Creating new tag {next_version} on {repo_name}", file=sys.stderr) + ctx.run('git config --global user.name "github-actions[bot]"', hide=True) + ctx.run( + 'git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"', + hide=True, + ) ctx.run(f"git tag {next_version}") ctx.run(f"git push origin tag {next_version}") # This repo has changes, the next check is not needed From 3189a3369fd28af69aff375f23b7930d0bd37057 Mon Sep 17 00:00:00 2001 From: Nicolas Schweitzer Date: Fri, 12 Jul 2024 16:32:56 +0200 Subject: [PATCH 2/5] Add write permissions as we push tags --- .github/workflows/create_rc_pr.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create_rc_pr.yml b/.github/workflows/create_rc_pr.yml index d77d9ed21ddd5..80ef4bf3d093e 100644 --- a/.github/workflows/create_rc_pr.yml +++ b/.github/workflows/create_rc_pr.yml @@ -13,7 +13,8 @@ env: jobs: create_rc_pr: runs-on: ubuntu-latest - + permissions: + contents: write # push tags steps: - name: Checkout repository uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 From 93cdfd1499065b624baf7546dc666fb6fb731c5c Mon Sep 17 00:00:00 2001 From: Nicolas Schweitzer Date: Fri, 12 Jul 2024 16:39:12 +0200 Subject: [PATCH 3/5] Remove adding the tag as we are lacking permissions --- .github/workflows/create_rc_pr.yml | 2 -- tasks/release.py | 9 +-------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/create_rc_pr.yml b/.github/workflows/create_rc_pr.yml index 80ef4bf3d093e..99265a23f0638 100644 --- a/.github/workflows/create_rc_pr.yml +++ b/.github/workflows/create_rc_pr.yml @@ -13,8 +13,6 @@ env: jobs: create_rc_pr: runs-on: ubuntu-latest - permissions: - contents: write # push tags steps: - name: Checkout repository uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 diff --git a/tasks/release.py b/tasks/release.py index db4eeb1a7df6b..2af70cc42e6ee 100644 --- a/tasks/release.py +++ b/tasks/release.py @@ -930,14 +930,7 @@ def check_for_changes(ctx, release_branch, warning_mode=False): if repo_name not in ["datadog-agent", "integrations-core"]: with clone(ctx, repo_name, repo['branch'], options="--filter=blob:none --no-checkout"): # We can add the new commit now to be used by release candidate creation - print(f"Creating new tag {next_version} on {repo_name}", file=sys.stderr) - ctx.run('git config --global user.name "github-actions[bot]"', hide=True) - ctx.run( - 'git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"', - hide=True, - ) - ctx.run(f"git tag {next_version}") - ctx.run(f"git push origin tag {next_version}") + print(f"Should create new tag {next_version} on {repo_name}", file=sys.stderr) # This repo has changes, the next check is not needed continue if repo_name != "datadog-agent" and last_tag_name != repo['previous_tag']: From 6b66490ee4b601700ababb147cb961a6d7b6cc79 Mon Sep 17 00:00:00 2001 From: Nicolas Schweitzer Date: Fri, 12 Jul 2024 17:11:09 +0200 Subject: [PATCH 4/5] another test --- .github/workflows/create_rc_pr.yml | 2 +- tasks/release.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create_rc_pr.yml b/.github/workflows/create_rc_pr.yml index 99265a23f0638..c3fef65542567 100644 --- a/.github/workflows/create_rc_pr.yml +++ b/.github/workflows/create_rc_pr.yml @@ -42,7 +42,7 @@ jobs: - name: Checkout release branch uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: - ref: ${{ env.RELEASE_BRANCH }} + ref: nschweitzer/add_git_config fetch-depth: 0 - name: Check for changes since last RC diff --git a/tasks/release.py b/tasks/release.py index 2af70cc42e6ee..6653bfce92ded 100644 --- a/tasks/release.py +++ b/tasks/release.py @@ -931,6 +931,13 @@ def check_for_changes(ctx, release_branch, warning_mode=False): with clone(ctx, repo_name, repo['branch'], options="--filter=blob:none --no-checkout"): # We can add the new commit now to be used by release candidate creation print(f"Should create new tag {next_version} on {repo_name}", file=sys.stderr) + ctx.run('git config --global user.name "github-actions[bot]"', hide=True) + ctx.run( + 'git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"', + hide=True, + ) + ctx.run(f"git tag {next_version}") + ctx.run(f"git push origin tag {next_version}") # This repo has changes, the next check is not needed continue if repo_name != "datadog-agent" and last_tag_name != repo['previous_tag']: From 797fee015a06f469b3c715594e0ff42f712b3430 Mon Sep 17 00:00:00 2001 From: Nicolas Schweitzer Date: Fri, 12 Jul 2024 17:13:26 +0200 Subject: [PATCH 5/5] remove again tagging --- .github/workflows/create_rc_pr.yml | 4 ++-- tasks/release.py | 13 +++---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/create_rc_pr.yml b/.github/workflows/create_rc_pr.yml index c3fef65542567..0a87e11fb7f6e 100644 --- a/.github/workflows/create_rc_pr.yml +++ b/.github/workflows/create_rc_pr.yml @@ -48,10 +48,10 @@ jobs: - name: Check for changes since last RC id: check_for_changes run: | - echo "CHANGES=$(inv -e release.check-for-changes -r ${{ env.RELEASE_BRANCH }} ${{ env.WARNING }})" >> $GITHUB_OUTPUT + echo "DD_CHANGES=$(inv -e release.check-for-changes -r ${{ env.RELEASE_BRANCH }} ${{ env.WARNING }})" >> $GITHUB_ENV - name: Create RC PR - if: ${{ steps.check_for_changes.outputs.CHANGES == 'true'}} + if: ${{ env.DD_CHANGES == '1' }} run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" diff --git a/tasks/release.py b/tasks/release.py index 6653bfce92ded..86e3059966956 100644 --- a/tasks/release.py +++ b/tasks/release.py @@ -916,12 +916,12 @@ def check_for_changes(ctx, release_branch, warning_mode=False): """ next_version = next_rc_version(ctx, "7") repo_data = generate_repo_data(warning_mode, next_version, release_branch) - changes = 'false' + changes = 0 for repo_name, repo in repo_data.items(): head_commit = get_last_commit(ctx, repo_name, repo['branch']) last_tag_commit, last_tag_name = get_last_tag(ctx, repo_name, next_version.tag_pattern()) if last_tag_commit != "" and last_tag_commit != head_commit: - changes = 'true' + changes = 1 print(f"{repo_name} has new commits since {last_tag_name}", file=sys.stderr) if warning_mode: emails = release_manager(repo_name, repo['branch']) @@ -931,17 +931,10 @@ def check_for_changes(ctx, release_branch, warning_mode=False): with clone(ctx, repo_name, repo['branch'], options="--filter=blob:none --no-checkout"): # We can add the new commit now to be used by release candidate creation print(f"Should create new tag {next_version} on {repo_name}", file=sys.stderr) - ctx.run('git config --global user.name "github-actions[bot]"', hide=True) - ctx.run( - 'git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"', - hide=True, - ) - ctx.run(f"git tag {next_version}") - ctx.run(f"git push origin tag {next_version}") # This repo has changes, the next check is not needed continue if repo_name != "datadog-agent" and last_tag_name != repo['previous_tag']: - changes = 'true' + changes = 1 print( f"{repo_name} has a new tag {last_tag_name} since last release candidate (was {repo['previous_tag']})", file=sys.stderr,