diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..698015b7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,23 @@ +# Changelog + +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.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- Support DeleteRegisteredModelAlias endpoint (#48). + +### Fixed + +- Add alias for ui (#112). +- Add better message for file store uris. (#114). + +## [0.1.0] - 2025-01-22 + +### Miscellaneous + +- Initial release! \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c3dff48b..4ac70f21 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,6 +24,7 @@ - [Run tests](#run-tests) - [Debug Failing Tests](#debug-failing-tests) - [Targeting Local Postgres in Python Tests](#targeting-local-postgres-in-python-tests) + - [Release Process](#release-process) @@ -353,4 +354,13 @@ def test_search_runs_datasets(): store = SqlAlchemyStore(db_uri, artifact_uri.as_uri()) ``` -in the test file located in `.mlflow.repo`. \ No newline at end of file +in the test file located in `.mlflow.repo`. + +## Release Process + +Currently, the release process is not fully automated. The maintainers need to follow these steps: + +- Ensure the [CHANGELOG.md](./CHANGELOG.md) file is up to date and contains a new `## [version]` heading for the version you wish to publish. +- Build a wheel locally and perform a sanity check to verify that your new version has been picked up. +- Create a release (via the GitHub website) and tag it with the version you just created. You can copy your release notes from the changelog. +- Once a tag is created, the [GitHub release workflow](./.github/workflows/release.yml) will automatically publish to PyPI. \ No newline at end of file diff --git a/magefiles/build.go b/magefiles/build.go index dd73912e..bcad7347 100644 --- a/magefiles/build.go +++ b/magefiles/build.go @@ -4,11 +4,91 @@ package main import ( + "bufio" + "errors" + "fmt" + "log" + "os" + "regexp" + "strings" + "github.com/magefile/mage/sh" ) +var errNoVersionInChangelog = errors.New("no version found in changelog") + +const writeFilePermission = 0o600 + +// Update the pyproject.toml version based on the changelog. +func updateVersionFromChangelog(changelogPath, pyprojectPath string) error { + // Define the regex pattern to match a version line, e.g., ## [0.1.0] + versionPattern := regexp.MustCompile(`\#\# \[(\d+\.\d+.\d+)\]`) + + // Open the changelog file + file, err := os.Open(changelogPath) + if err != nil { + return fmt.Errorf("failed to open changelog: %w", err) + } + defer file.Close() + + // Find the first matching version + var version string + + scanner := bufio.NewScanner(file) + for scanner.Scan() { + line := scanner.Text() + + matches := versionPattern.FindStringSubmatch(line) + if len(matches) > 1 { + version = matches[1] + + break + } + } + + if err := scanner.Err(); err != nil { + return fmt.Errorf("error reading changelog: %w", err) + } + + if version == "" { + return errNoVersionInChangelog + } + + // Read the pyproject.toml file + pyproject, err := os.ReadFile(pyprojectPath) + if err != nil { + return fmt.Errorf("failed to read pyproject.toml: %w", err) + } + + // Update the version in the pyproject.toml file + lines := strings.Split(string(pyproject), "\n") + for i, line := range lines { + if strings.HasPrefix(line, "version =") { + lines[i] = fmt.Sprintf("version = \"%s\"", version) + + break + } + } + + // Write the updated pyproject.toml back + updatedPyproject := strings.Join(lines, "\n") + + err = os.WriteFile(pyprojectPath, []byte(updatedPyproject), writeFilePermission) + if err != nil { + return fmt.Errorf("failed to write updated pyproject.toml: %w", err) + } + + log.Printf("Updated version in pyproject.toml to %s\n", version) + + return nil +} + // Build a Python wheel. func Build(goos, goarch string) error { + if err := updateVersionFromChangelog("CHANGELOG.md", "pyproject.toml"); err != nil { + return err + } + if err := sh.RunWithV(map[string]string{ "TARGET_GOOS": goos, "TARGET_GOARCH": goarch,