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: add pre releases config and job #2874

Open
wants to merge 8 commits into
base: next
Choose a base branch
from

Conversation

massao
Copy link
Contributor

@massao massao commented Sep 12, 2024

Purpose of PR

We want to make it possible to automatically release new alpha versions on the next branch.

Copy link

changeset-bot bot commented Sep 12, 2024

⚠️ No Changeset found

Latest commit: f0da549

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Sep 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
forma-36 ✅ Ready (Inspect) Visit Preview Sep 20, 2024 9:45am

"@contentful/f36-modal": "4.68.1",
"@contentful/f36-multiselect": "4.24.0",
"@contentful/f36-navbar": "5.0.0-alpha.35",
"@contentful/f36-navlist": "4.1.0-alpha.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This and the progress-stepper won't be bumped to the v5 when leaving the prerelease mode

@@ -139,6 +139,33 @@ jobs:
command: |
npm run-script changeset:publish

release_next:
Copy link
Contributor Author

@massao massao Sep 12, 2024

Choose a reason for hiding this comment

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

Do we need to also add these changes to the main branch, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think so, isn't it only Vault that only works on main?

RELEASES.md Outdated
Comment on lines 90 to 164
## Next branch

The next branch is used for the new version of Forma 36, which will probably have breaking changes. To help the development of the new packages, we have setup an automatic publishing of the packages on that branch to the `alpha` tag.
These packages aren't shown on the website as they can have breaking changes often.

### How to automatic publish

To make changeset publish a new version of the packages it's the same as in the `main` branch, it just requires having a changeset generated and specifing the packages.
Differently from the `main` branch, neither the packages changelog or the **What's new page** will be updated, and the changeset files will not be removed.

### Changeset configuration

To make it possible we take advantage of changeset feature of prereleasing, to make it possible we have the [.changeset/pre.json](./.changeset/pre.json) which specifies which tag to use and the initial version of the packages, which is used to calculate the alpha version, for example:

```
initial version: 4.61.2

For that initial version, each type of changeset would update as following:
patch: 4.61.3-alpha.0
minor: 4.62.0-alpha.0
major: 5.0.0-alpha.0

If the initial version is already on the alpha tag, either version would bump the alpha.[x]
```

_In our case we want all changes to be major so we work on the following major release._

**Config file explanation**

The main differences on the config file are the following:

```js
{
"changelog": false // This is set so the changelog of the packages is not updated
"ignore": [] // We don't want to ignore any package on the next branch
"fixed": [] // We don't want to have fixed or linked versions of alpha releases
"baseBranch": "next", // The branch which changesets uses to check versions
"bumpVersionsWithWorkspaceProtocolOnly": true, // Avoid bumping dependencies on other packages
}
```

Notes:

- The changelog is not updated because when we exit the prerelease state the changeset will compile all the changesets and apply onto the new version. eg. 5.0.0 will have all the changesets of the 5.0.0-alpha.\*
- The `bumpVersionsWithWorkspaceProtocolOnly` makes it possible to avoid bumping packages on the packages that are dependent on the pacakge being updated, this is because we want alpha packages to depend on stable packages, rather than have all of them depending on alpha packages. ie. we would make all packages bump to an alpha core in case we update it.

### Exiting prerelease

When exiting the prerelease state, to make the packages stable some steps are necessary:

```sh
# We need to revert the .changeset/config.json file to write the changelog files

npx changeset pre exit # This sets changeset to exit prerelease mode on the next changeset version

npm run changelog:gen # Generates the .changelogrc file that is used to update the What's new page

npx changeset version # This updates the packages changelogs and package.json

npx changeset publish # To publish the packages.
```

_Our CI already handles part of it, we would only need to revert the `.changeset/config.json` file and run the `npx changeset pre exit` command._

If the last commit on the branch before merging into `main` has those changes, the CI will handle the versioning, publishing and generating github releases as usual.

### Differences in the CI

The main difference in the release jobs on the CI, is that in the `next` branch we don't generate the `.changelogrc` file and don't generate the github releases.

Other than that the proccess is the same:

1. Build the packages
2. Update the versioning
3. commit the updated package.json file
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if something is not clear, or if you want to change something

type: 'confirm',
},
]);
if (skip) return;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this to discourage the usage of the script, or should we entirely remove it??

"access": "public",
"baseBranch": "main",
"baseBranch": "next",
Copy link
Collaborator

Choose a reason for hiding this comment

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

❓ these changes are only for the time while its a next branch or? So we will not merge it back to the main branch once we have the V5 finalized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because sadly we can't have mixed prereleases with releases, so we can only auto publish prereleases from the next branch.
And when merging it back to the main branch from the next, it would mean moving it to stable, for the main branch to auto publish it as stable, that I described on the RELEASES.md.

For alpha packages on the main branch we would still need to manually release sadly, or have two PRs, one pointing to the next branch to have the package published and one to the main branch to add the documentation.


### How to automatic publish

To make changeset publish a new version of the packages it's the same as in the `main` branch, it just requires having a changeset generated and specifing the packages.
Copy link
Collaborator

Choose a reason for hiding this comment

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

❓ will this also be the npx changeset command? Maybe would be good to add the exact command then also here in this seciton

Copy link
Contributor Author

@massao massao Sep 17, 2024

Choose a reason for hiding this comment

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

Yeah, that is the same command, I'll add the command on the documentation to make it clear.

I'll also update it to some steps that can be used locally to test the script as well

Copy link
Collaborator

@cf-remylenoir cf-remylenoir left a comment

Choose a reason for hiding this comment

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

Let's have a quick tour of these changes together, that would help me review better.


### Changeset configuration

To make it possible we take advantage of changeset feature of prereleasing, to make it possible we have the [.changeset/pre.json](./.changeset/pre.json) which specifies which tag to use and the initial version of the packages, which is used to calculate the alpha version, for example:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
To make it possible we take advantage of changeset feature of prereleasing, to make it possible we have the [.changeset/pre.json](./.changeset/pre.json) which specifies which tag to use and the initial version of the packages, which is used to calculate the alpha version, for example:
We use the pre-releasing changeset feature and the [.changeset/pre.json](./.changeset/pre.json), which specifies which tag to use and the packages' initial versions. It allows to control the alpha version bump, for example:

Comment on lines +174 to +177
Notes:

- The changelog is not updated because when we exit the prerelease state the changeset will compile all the changesets and apply onto the new version. eg. 5.0.0 will have all the changesets of the 5.0.0-alpha.\*
- The `bumpVersionsWithWorkspaceProtocolOnly` makes it possible to avoid bumping packages on the packages that are dependent on the pacakge being updated, this is because we want alpha packages to depend on stable packages, rather than have all of them depending on alpha packages. ie. we would make all packages bump to an alpha core in case we update it.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Notes:
- The changelog is not updated because when we exit the prerelease state the changeset will compile all the changesets and apply onto the new version. eg. 5.0.0 will have all the changesets of the 5.0.0-alpha.\*
- The `bumpVersionsWithWorkspaceProtocolOnly` makes it possible to avoid bumping packages on the packages that are dependent on the pacakge being updated, this is because we want alpha packages to depend on stable packages, rather than have all of them depending on alpha packages. ie. we would make all packages bump to an alpha core in case we update it.
> [!NOTE]
>
> - The changelog is not updated because after exiting the prerelease state, all the changesets will be compiled and applied to the new version. For example, `5.0.0` will have all the changesets of the `5.0.0-alpha.\*`
> - The `bumpVersionsWithWorkspaceProtocolOnly` prevents bumping packages' versions after a package they depend on is updated. This is because we want alpha packages to depend on stable packages. We would bump all packages to an alpha core if we allow it.

Comment on lines +108 to +110
It's possible to test how the version would change locally, make sure that your last changes are commited, and you can run the following commands depending on what needs to be tested.

Remember to revert the changes made through the `npx changeset version` and not commit them.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
It's possible to test how the version would change locally, make sure that your last changes are commited, and you can run the following commands depending on what needs to be tested.
Remember to revert the changes made through the `npx changeset version` and not commit them.
After committing your work, test the version's change by running these commands.
> [!WARNING]
> Remember to revert the changes made through the `npx changeset version` and not commit them.

Copy link
Collaborator

@cf-remylenoir cf-remylenoir left a comment

Choose a reason for hiding this comment

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

Thank you for expanding the release process documentation, I commented with some editorial nits ✍️

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