Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-timothy-albert committed May 30, 2024
1 parent 14c763c commit f0f4ae2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 10 deletions.
23 changes: 13 additions & 10 deletions pkg/releases/releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ func UpdateReleasesFile(releaseInfo ReleasesInfo, dir string) error {

var (
releaseInfoRegex = regexp.MustCompile(`(?s)## (.*?)\n### Changes\nBased on:\n- OpenAPI Doc (.*?) (.*?)\n- Speakeasy CLI (.*?) (\((.*?)\))?.*?`)
generatedLanguagesRegex = regexp.MustCompile(`- \[([a-z]+) v(\d+\.\d+\.\d+)\] (.*)`)
npmReleaseRegex = regexp.MustCompile(`- \[NPM v(\d+\.\d+\.\d+)\] (https:\/\/www\.npmjs\.com\/package\/(.*?)\/v\/\d+\.\d+\.\d+) - (.*)`)
pypiReleaseRegex = regexp.MustCompile(`- \[PyPI v(\d+\.\d+\.\d+)\] (https:\/\/pypi\.org\/project\/(.*?)\/\d+\.\d+\.\d+) - (.*)`)
goReleaseRegex = regexp.MustCompile(`- \[Go v(\d+\.\d+\.\d+)\] (https:\/\/(github.com\/.*?)\/releases\/tag\/.*?\/?v\d+\.\d+\.\d+) - (.*)`)
composerReleaseRegex = regexp.MustCompile(`- \[Composer v(\d+\.\d+\.\d+)\] (https:\/\/packagist\.org\/packages\/(.*?)#v\d+\.\d+\.\d+) - (.*)`)
mavenReleaseRegex = regexp.MustCompile(`- \[Maven Central v(\d+\.\d+\.\d+)\] (https:\/\/central\.sonatype\.com\/artifact\/(.*?)\/(.*?)\/.*?) - (.*)`)
terraformReleaseRegex = regexp.MustCompile(`- \[Terraform v(\d+\.\d+\.\d+)\] (https:\/\/registry\.terraform\.io\/providers\/(.*?)\/(.*?)\/.*?) - (.*)`)
rubyGemReleaseRegex = regexp.MustCompile(`- \[Ruby Gems v(\d+\.\d+\.\d+)\] (https:\/\/rubygems\.org\/gems\/(.*?)\/versions\/.*?) - (.*)`)
nugetReleaseRegex = regexp.MustCompile(`- \[NuGet v(\d+\.\d+\.\d+)\] (https:\/\/www\.nuget\.org\/packages\/(.*?)\/\d+\.\d+\.\d+) - (.*)`)
swiftReleaseRegex = regexp.MustCompile(`- \[Swift Package Manager v(\d+\.\d+\.\d+)\] (https:\/\/(github.com\/.*?)\/releases\/tag\/.*?\/?v\d+\.\d+\.\d+) - (.*)`)
generatedLanguagesRegex = regexp.MustCompile(`- \[([a-z]+) v(\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?)] (.*)`)
npmReleaseRegex = regexp.MustCompile(`- \[NPM v(\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?)] (https:\/\/www\.npmjs\.com\/package\/(.*?)\/v\/\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?) - (.*)`)
pypiReleaseRegex = regexp.MustCompile(`- \[PyPI v(\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?)] (https:\/\/pypi\.org\/project\/(.*?)\/\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?) - (.*)`)
goReleaseRegex = regexp.MustCompile(`- \[Go v(\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?)] (https:\/\/(github.com\/.*?)\/releases\/tag\/.*?\/?v\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?) - (.*)`)
composerReleaseRegex = regexp.MustCompile(`- \[Composer v(\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?)] (https:\/\/packagist\.org\/packages\/(.*?)#v\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?) - (.*)`)
mavenReleaseRegex = regexp.MustCompile(`- \[Maven Central v(\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?)] (https:\/\/central\.sonatype\.com\/artifact\/(.*?)\/(.*?)\/.*?) - (.*)`)
terraformReleaseRegex = regexp.MustCompile(`- \[Terraform v(\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?)] (https:\/\/registry\.terraform\.io\/providers\/(.*?)\/(.*?)\/.*?) - (.*)`)
rubyGemReleaseRegex = regexp.MustCompile(`- \[Ruby Gems v(\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?)] (https:\/\/rubygems\.org\/gems\/(.*?)\/versions\/.*?) - (.*)`)
nugetReleaseRegex = regexp.MustCompile(`- \[NuGet v(\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?)] (https:\/\/www\.nuget\.org\/packages\/(.*?)\/\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?) - (.*)`)
swiftReleaseRegex = regexp.MustCompile(`- \[Swift Package Manager v(\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?)] (https:\/\/(github.com\/.*?)\/releases\/tag\/.*?\/?v\d+\.\d+\.\d+(?:-\w+(?:\.\w+)*)?) - (.*)`)
)

func GetLastReleaseInfo(dir string) (*ReleasesInfo, error) {
Expand Down Expand Up @@ -323,6 +323,9 @@ func ParseReleases(data string) (*ReleasesInfo, error) {
}
}

fmt.Println("INFO")
fmt.Println(info.Languages)

return info, nil
}

Expand Down
45 changes: 45 additions & 0 deletions pkg/releases/releases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,48 @@ Based on:
LanguagesGenerated: map[string]releases.GenerationInfo{},
}, *info)
}

func TestReleases_ParseCodatPreRelease_Success(t *testing.T) {
releasesStr := `
## Version 1.1.0
### Changes
Based on:
- OpenAPI Doc v1 https://api.codat.io/swagger/v1/swagger.json
- Speakeasy CLI 0.21.0 https://github.com/speakeasy-api/speakeasy
### Releases
- [NPM v1.1.0-alpha] https://www.npmjs.com/package/@codatio/codat-ts/v/1.1.0-alpha - typescript-client-sdk
- [PyPI v1.1.0-beta.1] https://pypi.org/project/codatapi/1.1.0-beta.1 - python-client-sdk
- [Go v1.1.0-alpha.12] https://github.com/speakeasy-sdks/codat-sdks/releases/tag/v1.1.0-alpha.12 - go-client-sdk`

info, err := releases.ParseReleases(releasesStr)

assert.NoError(t, err)
assert.Equal(t, releases.ReleasesInfo{
ReleaseTitle: "Version 1.1.0",
DocVersion: "v1",
DocLocation: "https://api.codat.io/swagger/v1/swagger.json",
SpeakeasyVersion: "0.21.0",
Languages: map[string]releases.LanguageReleaseInfo{
"typescript": {
PackageName: "@codatio/codat-ts",
Path: "typescript-client-sdk",
Version: "1.1.0-alpha",
URL: "https://www.npmjs.com/package/@codatio/codat-ts/v/1.1.0-alpha",
},
"python": {
PackageName: "codatapi",
Path: "python-client-sdk",
Version: "1.1.0-beta.1",
URL: "https://pypi.org/project/codatapi/1.1.0-beta.1",
},
"go": {
PackageName: "github.com/speakeasy-sdks/codat-sdks/go-client-sdk",
Path: "go-client-sdk",
Version: "1.1.0-alpha.12",
URL: "https://github.com/speakeasy-sdks/codat-sdks/releases/tag/v1.1.0-alpha.12",
},
},
LanguagesGenerated: map[string]releases.GenerationInfo{},
}, *info)
}

0 comments on commit f0f4ae2

Please sign in to comment.