|
| 1 | +# Contributing |
| 2 | + |
| 3 | +When contributing to this repository, please first discuss the change you wish to make via |
| 4 | +[GitHub issues](https://github.com/refinedmods/refinedarchitect-template/issues), [Discord](https://discordapp.com/invite/VYzsydb), |
| 5 | +or any other method with the owners of this repository before making a change. |
| 6 | + |
| 7 | +## Pull requests |
| 8 | + |
| 9 | +- Keep your pull request (PR) as small as possible, this makes reviewing easier. |
| 10 | +- Commits serve a clear purpose and have a fitting commit message. |
| 11 | +- Branches are kept up to date by rebasing (updating a branch by merging makes for a confusing Git history). |
| 12 | +- PRs are merged by merging the commits on top of the target branch (which is `develop`). |
| 13 | +- Remember to add your changes in `CHANGELOG.md`. If your changes are merely technical, it's not necessary to update the |
| 14 | + changelog as it's not relevant for users. |
| 15 | + |
| 16 | +### Commit messages |
| 17 | + |
| 18 | +Commit messages must adhere to [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). We |
| 19 | +use [Commitlint](https://commitlint.js.org/) to validate commit messages. |
| 20 | + |
| 21 | +We use |
| 22 | +the [conventional configuration](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional) |
| 23 | +for Commitlint. |
| 24 | + |
| 25 | +It is recommended to install |
| 26 | +the [Conventional Commit plugin](https://plugins.jetbrains.com/plugin/13389-conventional-commit) to make it |
| 27 | +easier to write commit messages. |
| 28 | + |
| 29 | +### Branch names |
| 30 | + |
| 31 | +Because we use merge commits when merging a PR, branch names will be part of the history of the repository. That is why |
| 32 | +branch names must follow a certain standard. |
| 33 | + |
| 34 | +The format is `{category}/GH-{issue number}/{lowercase-description}` and a branch name can be maximum 50 characters of |
| 35 | +length. |
| 36 | + |
| 37 | +Category must match a |
| 38 | +category [used in our Commitlint config](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional#type-enum). |
| 39 | + |
| 40 | +Valid examples are: |
| 41 | + |
| 42 | +- `fix/GH-123/add-branch-linting` |
| 43 | +- `docs/GH-123/cleanup` |
| 44 | + |
| 45 | +## Versioning |
| 46 | + |
| 47 | +This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 48 | + |
| 49 | +### Version metadata |
| 50 | + |
| 51 | +The code doesn't contain version metadata: `build.gradle` specifies a version of `0.0.0` (via Refined Architect). |
| 52 | +The versioning information is entirely contained in Git by using tags. |
| 53 | + |
| 54 | +Per [Semantic Versioning](https://semver.org/spec/v2.0.0.html), the version number being released depends on the changes |
| 55 | +in that release. We usually can't predict those |
| 56 | +changes at the start of a release cycle, so we can't bump the version at the start of a release cycle. That means that |
| 57 | +the version number being released is determined at release time. |
| 58 | + |
| 59 | +Because the version number is determined at release time, we can't store any versioning metadata in the |
| 60 | +code (`build.gradle`). If we did, `build.gradle` would have the version number of the latest released version during the |
| 61 | +release cycle of the new version, which isn't correct. |
| 62 | + |
| 63 | +## Changelog |
| 64 | + |
| 65 | +The changelog is kept in `CHANGELOG.md`. |
| 66 | + |
| 67 | +Keeping a readable, relevant and user-friendly changelog is essential for our end users |
| 68 | +to stay up to date with the project. |
| 69 | + |
| 70 | +Please refrain from using technical terminology or adding entries for technical changes |
| 71 | +that are (generally) not relevant to the end-user. |
| 72 | + |
| 73 | +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). |
| 74 | + |
| 75 | +## Gitflow |
| 76 | + |
| 77 | +This project uses [Gitflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow). |
| 78 | + |
| 79 | +## Code style |
| 80 | + |
| 81 | +We use [Checkstyle](https://checkstyle.sourceforge.io/) in our build workflow to validate coding style. |
| 82 | + |
| 83 | +It is recommended to import the [config/checkstyle/checkstyle.xml](../config/checkstyle/checkstyle.xml) file into your |
| 84 | +IDE, so that formatting rules are respected. |
| 85 | + |
| 86 | +Moreover, the [CheckStyle-IDEA plugin](https://plugins.jetbrains.com/plugin/1065-checkstyle-idea) can be used to check |
| 87 | +if there are no style violations. |
| 88 | + |
| 89 | +## Release process |
| 90 | + |
| 91 | +The release process is automated and follows Gitflow. |
| 92 | + |
| 93 | +Before running the "Draft release" workflow to start the release process make sure `CHANGELOG.md` contains all the |
| 94 | +unreleased changes. |
| 95 | + |
| 96 | +To determine the version number to be released, the workflow will ask you which release type this is (major, minor, |
| 97 | +patch). |
| 98 | +The latest version from `CHANGELOG.md` will be used as a base, and that will be incremented |
| 99 | +depending on the release type. |
| 100 | + |
| 101 | +`CHANGELOG.md` will be updated by this workflow, you can review this in the resulting release PR. |
| 102 | + |
| 103 | +If you merge the release PR, the "Publish release" workflow will automatically publish the release. An additional PR |
| 104 | +will be created to merge the changes in `CHANGELOG.md` back into `develop`. |
| 105 | + |
| 106 | +## Hotfix process |
| 107 | + |
| 108 | +The hotfix process is semi-automated and follows Gitflow: |
| 109 | + |
| 110 | +- Create a hotfix branch off `main`. |
| 111 | +- Commit your changes on this branch. |
| 112 | +- Update `CHANGELOG.md` (with version number and release date) manually on this branch. |
| 113 | +- Push the branch and create a PR for it, merging into `main`. |
| 114 | + |
| 115 | +The "Publish release" workflow will take care of the rest. |
| 116 | + |
| 117 | +## Workflows |
| 118 | + |
| 119 | +We have a few GitHub workflows: |
| 120 | + |
| 121 | +- Build (PRs, pushes to `develop` and `main`) |
| 122 | +- Draft release (manual trigger) |
| 123 | +- Publish release (merging a PR to `main`) |
| 124 | +- Validate changelog (PRs) |
| 125 | + - To validate if `CHANGELOG.md` is valid and updated. |
| 126 | + - Not every pull request needs a changelog change, so the `skip-changelog` label can be added to the pull request to |
| 127 | + ignore this. |
| 128 | +- Validate commit messages (PRs) |
| 129 | + - Validates whether the commits on a pull request |
| 130 | + respect [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). |
| 131 | + - We use |
| 132 | + the [conventional configuration](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional). |
| 133 | +- Validate branch names (PRs) |
| 134 | +- Issue for unsupported version (issues) |
| 135 | + - Posts a message on a GitHub issue if the issue is about an unsupported version. |
| 136 | +- Lock resolved issues and PRs (every night) |
| 137 | + |
| 138 | +### Build |
| 139 | + |
| 140 | +The build workflow triggers when a pull request is updated or when a commit is pushed to `develop` or `main`. |
| 141 | + |
| 142 | +The build workflow takes care of the following: |
| 143 | + |
| 144 | +- Running a Gradle build. |
| 145 | +- Code style validation with Checkstyle. |
| 146 | +- Uploading the artifacts on the action. |
| 147 | + |
| 148 | +### Draft release |
| 149 | + |
| 150 | +The draft release workflow is a manual workflow which will create a release branch from `develop`. |
| 151 | + |
| 152 | +To determine the version number to be released, it will extract the latest version number from `CHANGELOG.md` and |
| 153 | +increment it depending on the release type selected. |
| 154 | + |
| 155 | +This workflow takes care of the following: |
| 156 | + |
| 157 | +- Creating the release branch. |
| 158 | +- Updating the changelog on this release branch. |
| 159 | +- Creating a pull request merging the release branch into `main`. |
| 160 | + |
| 161 | +### Publish release |
| 162 | + |
| 163 | +The "publish release" workflow is triggered when a release or hotfix PR is merged to `main`. Usually, this will be the |
| 164 | +PR created earlier in the "Draft release" workflow. |
| 165 | + |
| 166 | +The workflow takes care of the following: |
| 167 | + |
| 168 | +- Extracting the version number from the release or hotfix branch name that is merged in the PR. |
| 169 | +- Extracting the changelog entry for this version number. |
| 170 | +- Running a build. |
| 171 | +- Publishing on [GitHub packages](https://github.com/refinedmods/refinedarchitect-template/packages) and |
| 172 | + CreeperHost Maven. |
| 173 | +- Publishing Javadoc on [GitHub pages](https://github.com/refinedmods/refinedarchitect-template/tree/gh-pages). |
| 174 | +- Deploying on [GitHub releases](https://github.com/refinedmods/refinedarchitect-template/releases). |
| 175 | +- Announcing the release on Discord and Twitter. |
| 176 | +- Creating a PR that merges `main` back into `develop` to get the changes to `CHANGELOG.md` and `build.gradle` |
| 177 | + into `develop` from the draft release workflow. |
0 commit comments