Skip to content

Commit

Permalink
Add initial changelog process (#115)
Browse files Browse the repository at this point in the history
Signed-off-by: nojaf <florian.verdonck@outlook.com>
  • Loading branch information
nojaf authored Jan 23, 2025
1 parent ed0105f commit 8a621cc
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 1 deletion.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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!
12 changes: 11 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down Expand Up @@ -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`.
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.
80 changes: 80 additions & 0 deletions magefiles/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8a621cc

Please sign in to comment.