Skip to content

Commit

Permalink
fix: version string
Browse files Browse the repository at this point in the history
  • Loading branch information
futrime committed Feb 4, 2024
1 parent 060f532 commit 70766fc
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.20.1] - 2024-02-04

### Fixed

- Version string.

## [0.20.0] - 2024-02-03

### Added
Expand Down Expand Up @@ -377,6 +383,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Basic functions: cache, install, list, show, tooth init, and uninstall.

[0.20.1]: https://github.com/lippkg/lip/compare/v0.20.0...v0.20.1
[0.20.0]: https://github.com/lippkg/lip/compare/v0.19.0...v0.20.0
[0.19.0]: https://github.com/lippkg/lip/compare/v0.18.1...v0.19.0
[0.18.1]: https://github.com/lippkg/lip/compare/v0.18.0...v0.18.1
Expand Down
2 changes: 1 addition & 1 deletion cmd/lip/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var defaultConfig context.Config = context.Config{
GoModuleProxyURL: "https://goproxy.io",
}

var lipVersion semver.Version = semver.MustParse("0.19.0")
var lipVersion semver.Version = semver.MustParse("0.20.1")

func main() {
log.SetFormatter(&nested.Formatter{})
Expand Down
76 changes: 76 additions & 0 deletions scripts/validate_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import argparse
import re
import subprocess
from typing import TypedDict


class Args(TypedDict):
tag: str


def main():
args = get_args()

version = args["tag"].lstrip("v")

validate_changelog(version)
validate_code(version)

changelog_current_version_content = get_changelog_current_version_content(version)

print("## What's Changed:")
print(changelog_current_version_content)


def get_args() -> Args:
parser = argparse.ArgumentParser()
parser.add_argument("--tag", required=True)

args = parser.parse_args()

return {
"tag": args.tag,
}


def get_changelog_current_version_content(version: str) -> str:
with open("CHANGELOG.md", "r", encoding="utf-8") as f:
content = f.read()

regex = r"## \[{}\] - .*?\n(.*?)## \[".format(version)

result = re.search(regex, content, re.DOTALL)

if not result:
raise Exception("CHANGELOG.md lacks version {}".format(version))

return result.group(1)


def validate_changelog(version: str):
try:
subprocess.run(
f"npx changelog --format markdownlint",
shell=True,
check=True,
)
except subprocess.CalledProcessError as e:
print("Have you installed it by `npm i -g keep-a-changelog`?")
raise e

with open("CHANGELOG.md", "r", encoding="utf-8") as f:
content = f.read()

if not re.search(r"## \[{}\]".format(version), content):
raise Exception("CHANGELOG.md lacks version {}".format(version))


def validate_code(version: str):
with open("cmd/lip/main.go", "r", encoding="utf-8") as f:
content = f.read()

if not re.search(r'semver\.MustParse\("{}"\)'.format(version), content):
raise Exception("cmd/lip/main.go lacks version {}".format(version))

if __name__ == "__main__":
main()

0 comments on commit 70766fc

Please sign in to comment.