Skip to content

Instantly share code, notes, and snippets.

@jasperf
Last active April 4, 2025 03:15
Show Gist options
  • Save jasperf/55c83eb8e431eb7147f3d6269a9e463a to your computer and use it in GitHub Desktop.
Save jasperf/55c83eb8e431eb7147f3d6269a9e463a to your computer and use it in GitHub Desktop.
By following this Git versioning scheme, you ensure that the latest version always appears at the top of the list in Packagist.

To ensure that the versions are listed in the correct order with the latest on top in Packagist, you should follow semantic versioning and use proper pre-release identifiers. Here are some recommendations:

  1. Semantic Versioning: Follow semantic versioning (SemVer) strictly. The format is MAJOR.MINOR.PATCH, where:

    • MAJOR version increments for incompatible changes.
    • MINOR version increments for backward-compatible functionality.
    • PATCH version increments for backward-compatible bug fixes.
  2. Pre-release Identifiers: Use pre-release identifiers (e.g., alpha, beta, rc) with a numeric suffix to maintain proper order. The format is MAJOR.MINOR.PATCH-<identifier>.<number>.

  3. Release Order: Ensure that the versions increment logically so that Packagist can sort them correctly.

Here is an example of how to version your releases:

  1. Initial Development:

    • v0.0.1-alpha.1
    • v0.0.1-alpha.2
    • v0.0.1-beta.1
    • v0.0.1-beta.2
    • v0.0.1-rc.1 (Release Candidate)
    • v0.0.1
  2. Subsequent Versions:

    • v0.1.0-alpha.1
    • v0.1.0-beta.1
    • v0.1.0
    • v1.0.0-alpha.1
    • v1.0.0-beta.1
    • v1.0.0-rc.1
    • v1.0.0

Using this approach, Packagist will list the versions correctly with the latest version at the top. Here is how the sorted order would look:

  1. v1.0.0
  2. v1.0.0-rc.1
  3. v1.0.0-beta.1
  4. v1.0.0-alpha.1
  5. v0.1.0
  6. v0.1.0-beta.1
  7. v0.1.0-alpha.1
  8. v0.0.1
  9. v0.0.1-rc.1
  10. v0.0.1-beta.2
  11. v0.0.1-beta.1
  12. v0.0.1-alpha.2
  13. v0.0.1-alpha.1

By following this versioning scheme, you ensure that the latest version always appears at the top of the list in Packagist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment