Skip to content

Use xmake publish to publish the project libraries as package to repositories #7161

@waruqi

Description

@waruqi

Currently, these are just early ideas and some design drafts.

While using remote repository packages is now quite convenient, distributing and integrating libraries into your own project can still be somewhat complex. (See: https://xmake.io/guide/package-management/distribute-private-libraries.html)

We can provide xmake publish plugin command to publish own project libraries to remote/local repositories. like maven publish, ./gradle uploadArchives, ...

We can publish our project's libraries to private remote repositories, local repositories, and the official xmake repository.

Custom publication configuration

includes("@builtin/publication")

publication("publication_name")
    set_version("1.0")
    add_targets("foo", "bar")
    set_repository("https://github.com/xmake-io/xmake-repo")
    set_authorization("...")

We can custom publish logic code.

includes("@builtin/publication")

publication("publication_name")
    set_version("1.0")
    add_targets("foo", "bar")
    on_publish(function ()
         -- ...
    end)

Publish to the given private remote repositories

-- using the default publication configuration to publish
xmake publish

-- using the given custom publication configuration to publish in project xmake.lua
xmake publish --publication=[name]

-- publish to the given version and repository
xmake publish [-v 1.0] [--repo=name or url]

-- publish the given targets
xmake publish --targets=foo,bar

-- force to re-publish (override existing package)
xmake publish --force

Publish to the official xmake-repo repository.

We can also automatically create pull requests and submit them to the official xmake-repo repository.

xmake publish --publication=official

We will include some predefined publication configurations to quickly publish to the official xmake-repo repository, as well as other package repositories such as vcpkg, conan, etc.

xmake publish --publication=vcpkg
xmake publish --publication=conan
xmake publish --publication= ...

Publish to the local package repositores

xmake publish --local
xmake publish --local -repo=[name or url] 

Integrate the published packages

If the repository has already been added globally, we do not need to use add_repositories to configure the package repository separately.

add_requires("xxx")

The difference from xmake install

This is different from and does not conflict with xmake install. xmake install is only used to install to the system environment, making it convenient for third-party projects to use. However, for internal integration within an xmake project, this method is not recommended. Using packages for maintenance is a more user-friendly approach and avoids polluting the system environment.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions