Skip to content

Instantly share code, notes, and snippets.

@zhuqling
Created October 23, 2018 01:44
Show Gist options
  • Save zhuqling/4145d940f22c517b413d932b4d95e0de to your computer and use it in GitHub Desktop.
Save zhuqling/4145d940f22c517b413d932b4d95e0de to your computer and use it in GitHub Desktop.
sem version版本定义

规则:[major, minor, patch]

  • x.y.z := 主版本.次版本.修订号

标准的版本号“必须 MUST ”采用 XYZ 的格式,其中 X、Y 和 Z 为非负的整数,且“禁止 MUST NOT”在数字前方补零。X 是主版本号、Y 是次版本号、而 Z 为修订号。每个元素“必须 MUST ”以数值来递增。例如:1.9.1 -> 1.10.0 -> 1.11.0。

标记版本号的软件发行后,“禁止 MUST NOT ”改变该版本软件的内容。任何修改都“必须 MUST ”以新版本发行。

主版本号为零(0.y.z)的软件处于开发初始阶段,一切都可能随时被改变。这样的公共 API 不应该被视为稳定版。

1.0.0 的版本号用于界定公共 API 的形成。这一版本之后所有的版本号更新都基于公共 API 及其修改内容。

修订号 Z(x.y.Z | x > 0)“必须 MUST ”在只做了向下兼容的修正时才递增。这里的修正指的是针对不正确结果而进行的内部修改。

次版本号 Y(x.Y.z | x > 0)“必须 MUST ”在有向下兼容的新功能出现时递增。在任何公共 API 的功能被标记为弃用时也“必须 MUST ”递增。也“可以 MAY ”在内部程序有大量新功能或改进被加入时递增,其中“可以 MAY ”包括修订级别的改变。每当次版本号递增时,修订号“必须 MUST ”归零。

主版本号 X(X.y.z | X > 0)“必须 MUST ”在有任何不兼容的修改被加入公共 API 时递增。其中“可以 MAY ”包括次版本号及修订级别的改变。每当主版本号递增时,次版本号和修订号“必须 MUST ”归零。

先行版本号“可以 MAY ”被标注在修订版之后,先加上一个连接号再加上一连串以句点分隔的标识符号来修饰。标识符号“必须 MUST ”由 ASCII 码的英数字和连接号 [0-9A-Za-z-] 组成,且“禁止 MUST NOT ”留白。数字型的标识符号“禁止 MUST NOT ”在前方补零。先行版的优先级低于相关联的标准版本。被标上先行版本号则表示这个版本并非稳定而且可能无法达到兼容的需求。范例:1.0.0-alpha、1.0.0-alpha.1、1.0.0-0.3.7、1.0.0-x.7.z.92。

范围(>,>=,<,<=) Ranges

  • < Less than
  • <= Less than or equal to
  • Greater than

  • = Greater than or equal to

  • = Equal. If no operator is specified, then equality is assumed, so this operator is optional, but MAY be included.

连续范围(-) Hyphen Ranges X.Y.Z - A.B.C

  • 1.2.3 - 2.3.4 := >=1.2.3 <=2.3.4
  • 1.2 - 2.3.4 := >=1.2.0 <=2.3.4
  • 1.2.3 - 2.3 := >=1.2.3 <2.4.0
  • 1.2.3 - 2 := >=1.2.3 <3.0.0

x范围(, x) X-Ranges 1.2.x 1.X 1.2. *

    • := >=0.0.0 (Any version satisfies)
  • 1.x := >=1.0.0 <2.0.0 (Matching major version)

  • 1.2.x := >=1.2.0 <1.3.0 (Matching major and minor versions)

  • "" (empty string) := * := >=0.0.0

  • 1 := 1.x.x := >=1.0.0 <2.0.0

  • 1.2 := 1.2.x := >=1.2.0 <1.3.0

约范围(~) Tilde Ranges ~1.2.3 ~1.2 ~1

  • ~1.2.3 := >=1.2.3 <1.(2+1).0 := >=1.2.3 <1.3.0
  • ~1.2 := >=1.2.0 <1.(2+1).0 := >=1.2.0 <1.3.0 (Same as 1.2.x)
  • ~1 := >=1.0.0 <(1+1).0.0 := >=1.0.0 <2.0.0 (Same as 1.x)
  • ~0.2.3 := >=0.2.3 <0.(2+1).0 := >=0.2.3 <0.3.0
  • ~0.2 := >=0.2.0 <0.(2+1).0 := >=0.2.0 <0.3.0 (Same as 0.2.x)
  • ~0 := >=0.0.0 <(0+1).0.0 := >=0.0.0 <1.0.0 (Same as 0.x)
  • ~1.2.3-beta.2 := >=1.2.3-beta.2 <1.3.0 Note that prereleases in the 1.2.3 version will be allowed, if they are greater than or equal to beta.2. So, 1.2.3-beta.4 would be allowed, but 1.2.4-beta.2 would not, because it is a prerelease of a different [major, minor, patch] tuple.

上范围(^) Caret Ranges ^1.2.3 ^0.2.5 ^0.0.4

  • ^1.2.3 := >=1.2.3 <2.0.0

  • ^0.2.3 := >=0.2.3 <0.3.0

  • ^0.0.3 := >=0.0.3 <0.0.4

  • ^1.2.3-beta.2 := >=1.2.3-beta.2 <2.0.0 Note that prereleases in the 1.2.3 version will be allowed, if they are greater than or equal to beta.2. So, 1.2.3-beta.4 would be allowed, but 1.2.4-beta.2 would not, because it is a prerelease of a different [major, minor, patch] tuple.

  • ^0.0.3-beta := >=0.0.3-beta <0.0.4 Note that prereleases in the 0.0.3 version only will be allowed, if they are greater than or equal to beta. So, 0.0.3-pr.2 would be allowed.

  • ^1.2.x := >=1.2.0 <2.0.0

  • ^0.0.x := >=0.0.0 <0.1.0

  • ^0.0 := >=0.0.0 <0.1.0

  • ^1.x := >=1.0.0 <2.0.0

  • ^0.x := >=0.0.0 <1.0.0

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