Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Adds new step in release process for updating header of changelog #2134

Merged
merged 4 commits into from
Apr 12, 2024

Conversation

AgustinBettati
Copy link
Member

@AgustinBettati AgustinBettati commented Apr 10, 2024

Description

Link to any related issue(s): CLOUDP-241731

Defines a new job that automatically adjusts the CHANGELOG.md header section during a new release.

This PR contemplates the possibility of doing pre-releases (by skipping this job), this will not be needed for our regular release process but could be useful in the future if we want to share a preview to customers (pointed out by Melissa in the scope).

Testing

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals, I defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@AgustinBettati AgustinBettati marked this pull request as ready for review April 11, 2024 08:59
@AgustinBettati AgustinBettati requested a review from a team as a code owner April 11, 2024 08:59
steps:
- name: Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || github.ref }}
ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || 'master' }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to define master to make sure latest commit is used, more details here actions/checkout#439 (comment)

- name: Create release tag
uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72
with:
tag: ${{ inputs.version_number }}
commit_sha: ${{ steps.get-sha.outputs.sha }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed so tag is added into latest commit, if not the sha used for triggering the workflow is used: actions/checkout#439 (comment)

@@ -0,0 +1,30 @@
#!/usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if the Unreleased section was already modified before, e.g. this already ran and we're running release workflow again?

will it fail or will do nothing silently?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script will output a message like CHANGELOG already has a header defined for 1.16.0, no changes made to changelog. (example: https://github.com/AgustinBettati/terraform-provider-mongodbatlas/actions/runs/8638524825/job/23683156506).

@@ -22,31 +22,66 @@ jobs:
run: |
echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+(-pre[A-Za-z0-9-]*)?$'
Copy link
Member

@lantoli lantoli Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once the release is finished successfully, do we need to put the Unrelease header again in the file?

Copy link
Collaborator

@oarbusi oarbusi Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what I see here, Unreleased header is never removed and the new versions are always put after the unreleased header

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the Unreleased header is preserved at the top of the changelog, example commit.

runs-on: ubuntu-latest
needs: [ validate-version-input, run-qa-acceptance-tests ]
if: ${{ always() && needs.validate-version-input.result == 'success' && (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success') }}
# Skipped if use_existing_tag is defined, is a pre-release, or previous jobs failed.
if: >-
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

knitpit: this condition is a bit complex

git config --local user.name changelogbot
git add CHANGELOG.md
git commit -m "$MSG"
git push
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to previous comment, if there is no change to the file because was already updated, is an empty commit pushed or no action is done?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if no change to the file is done $(git status --porcelain) will be false and no action is done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see. a small issue that could happen is that we start release one afternoon, there are some problems, we finish the release next day, but the changelog release section date is yesterday

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, not sure if the concern is worth making the solution more complex (check if header of current release is present and updating the date). If it ever becomes a significant gap a commit can adjust the date before or after the release.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree not to address it now

runs-on: ubuntu-latest
needs: [ validate-version-input, run-qa-acceptance-tests ]
if: ${{ always() && needs.validate-version-input.result == 'success' && (needs.run-qa-acceptance-tests.result == 'skipped' || needs.run-qa-acceptance-tests.result == 'success') }}
# Skipped if use_existing_tag is defined, is a pre-release, or previous jobs failed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you are using or but if condition is all and. Which one is correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because the comment mentions when the job is skipped, while the if statement defines when it is run.

@AgustinBettati AgustinBettati merged commit 009f232 into master Apr 12, 2024
52 checks passed
@AgustinBettati AgustinBettati deleted the CLOUDP-241731 branch April 12, 2024 07:36
lantoli added a commit that referenced this pull request Apr 12, 2024
* master:
  chore: Sends Slack notification when changelog update fails (#2140)
  chore: Adds new step in release process for updating header of changelog (#2134)
  update to TF 1.8.0 (#2138)
  doc: Updates Terraform Compatibility Matrix documentation (#2137)
  chore: Adds workflow that generates changelog after PR is merged (#2128)
lantoli added a commit that referenced this pull request Apr 15, 2024
* master:
  fix: Removes default comment when creating resource `mongodbatlas_privatelink_endpoint_serverless` and adds update support to `mongodbatlas_privatelink_endpoint_service_serverless` (#2133)
  doc: Documents testing best practices (#2132)
  chore: Uses correct format when setting remote (#2147)
  chore: Configures git correctly for automatic commit (#2146)
  chore: Uses PAT of bot to commit changelog updates (#2144)
  doc: Adjust RELEASING.md documentation with new process (#2142)
  fix: Fixes nil pointer dereference if `advanced_configuration` update fails in `mongodbatlas_cluster` (#2139)
  chore: Adds a  new step in release process that marks Jira version as released (#2136)
  chore: Sends Slack notification when changelog update fails (#2140)
  chore: Adds new step in release process for updating header of changelog (#2134)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants