Skip to content

Instantly share code, notes, and snippets.

@MichalMichalak
Last active March 2, 2018 00:28
Show Gist options
  • Save MichalMichalak/f3244b35e6800764e56bf522e2602916 to your computer and use it in GitHub Desktop.
Save MichalMichalak/f3244b35e6800764e56bf522e2602916 to your computer and use it in GitHub Desktop.

Pipeline

Notes

  • PR means BitBucket's pull request.
  • Version suffixes, like -SNAPSHOT or -RC or -build are not used.
  • Git must be installed and be in the PATH.
  • Git tag format must be only version number. Any prefixes or suffixes are not allowerd.

Flow

  1. Developer must start from master branch.
  2. Developer must work on feature branch.
    1. The name of the branch must be short, yet must describe the purpose of the changes.
    2. Multiple words must be separated with hyphen, not underscore.
  3. Developer must commit a /.version.bump file.
    1. File must contain one of 3 words, major, minor or patch, to indicate which version should be bumped.
  4. Developer must checkout release_UNIQUE_ID branch from latest available master branch. This step should be done immediately before PR creation. Possibly, script should exist in project's directory to complete this step with as few manual steps as possible.
    1. Id should be unique, yet able to generate in deterministic manner as it will be used multiple times in independent pipeline steps.
  5. Developer must create PR from master to release_UNIQUE_ID branch. For the sake of simplicity let's assume feature is implemented properly and PR has got accepted.
  6. Developer must merge PR which will merge and push to release_UNIQUE_ID branch.
  7. On push to release_UNIQUE_ID the following steps must be executed by CI.
    1. Script must check if /.version.bump exists. If not, job must fail.
    2. Script must get the current version number from /.version file. If file doesn't exist, current version must be 0.0.1. If can't be read, job must fail.
    3. Script must generate new version number using /.version.bump file content.
      1. If current version is 0.0.1, file's content must not be patch. If it is, job must fail. A 0.0.1 is not allowed in SemVer but after major or minor increase it becomes 1.0.0 or 0.1.0, respectively, which are allowed.
      2. If file's content is major, increase major number and reset minor and patch numbers to zero.
      3. If file's content is minor, do not change major number, increase minor number, and reset patch number to zero.
      4. If file's content is patch, do not change major and minor numbers and increase patch number.
    4. Script must update version number to new one in /readme.md file.
    5. Script must update /changelog.md file (See: Keep a changelog for the spec.) If file doesn't exist, can't be read, job must fail.
      1. Script must change 'Unreleased' section title with new version and today's date. If section doesn't exist, job must fail.
      2. Script must add reference URL in the bottom, to have a new version pointing to changes between new and previous version.
    6. Script must write new version to /.version file overwriting existing file. Create file if not exists.
    7. Script must delete /.version.bump file.
    8. Script must commit changes with message Bump version to NEW_VERSION. Where NEW_VERSION is new version number.
    9. Script must set Git tag with new version.
    10. Script must merge release_UNIQUE_ID to master branch. If fails, job must fail.
    11. Script must push master branch. If fails, job must fail.
    12. Script must delete release_UNIQUE_ID branch. If fails, job must display warning.
  8. On push to master the following steps must be executed by CI.
    1. Script must check if /.version.bump exists. If yes, job must fail.
    2. Script must get version from /.version file. If file doesn't exists or can't be read, job must fail.
    3. Script must check if Git tag above version exists. If yes, job must fail.
    4. Gradle must build, run tests, publish to Nexus.
      1. Gradle script must set version property to a content of /.version file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment