Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for private indexes to "alr publish" #1745

Merged
merged 15 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions doc/catalog-format-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,18 @@ static, i.e. they cannot depend on the context.
"Bob For Instance <[email protected]>"]
```

- `maintainers-logins`: mandatory (for indexing) array of strings. Flat
list of github login usernames used by the maintainers of the crate. This
information is used to authorize crate modifications. For instance:
- `maintainers-logins`: optional array of non-empty strings.
For crates submitted to the community index, this is a mandatory flat list of
the GitHub login usernames authorized to modify the crate.
For instance:

```toml
maintainers-logins = ["alicehacks", "bobcoder"]
```

Private indexes may use whichever logins are appropriate for their
hosting arrangement, or none at all.

- `licenses`: mandatory (for indexing) string. A valid [SPDX
expression](https://spdx.org/licenses/). Custom license identifiers are
accepted with the format: `custom-[0-9a-zA-Z.-]+`
Expand Down
46 changes: 34 additions & 12 deletions doc/publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,37 @@ This will be shown as:

## Publishing to a local/private index

Having a local index may be useful sometimes, be it for local testing, or for
private crates not intended for publication.

There is no practical difference between the community index that is cloned
locally and a private local index stored on disk. Hence, after obtaining the
manifest file with `alr publish`, it is a matter of placing it at the expected
location within the index: `/path/to/index/cr/crate_name/crate_name-x.x.x.toml`

If the crate being published locally contains `"provides"` definitions, it is
necessary to call `alr index --update-all` once to ensure it is properly used
by the dependency solver. This is only necessary for the first release in a
crate that uses the `"provides"` feature.
Having a local or private index may be useful sometimes, be it for local
testing, or for private crates not intended for publication.

There is no practical difference between the community index and a private index
stored locally on disk or on your own infrastructure. An index must be located
in a first level subdirectory of an accessible git repository or local
filesystem location (or optionally at the top level in the case of a local
filesystem index). This subdirectory should contain only an `index.toml`
file and one or more `cr/crate_name` subdirectories within which the crate
manifests themselves are located. The `index.toml` file contains one line with
the form `version = "x.x.x"`, specifying the index format used. The range of
versions Alire is compatible with can be found by running `alr version`, and
breaking changes are listed in
[BREAKING.md](https://github.com/alire-project/alire/blob/master/BREAKING.md).

To start using such an index, run

`alr index --add=<URL> --name=<name>`,

where `<name>` is a human-friendly label that `alr` will use to refer to it.

To publish a crate to a private index, run

`alr publish --for-private-index [<path|URL> <commit|tag|branch>]`

as described in the sections above, then place the manifest file it generates at
the indicated path (relative to the location of `index.toml`).

Additions to indexes stored locally on the disk will take effect immediately,
unless the crate being published contains `"provides"` definitions, in which
case an index update will be required (either with `alr index --update-all`, or
through a scheduled auto-update) to ensure it is properly used by the dependency
solver. An index update will always be required when publishing to a git
repository index.
2 changes: 1 addition & 1 deletion scripts/ci-github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fi

# Disable distro detection if supported
if [ "${ALIRE_DISABLE_DISTRO:-}" == "true" ]; then
alr config --global --set distribution.disable_detection true
alr settings --global --set distribution.disable_detection true
fi

# For the record
Expand Down
5 changes: 4 additions & 1 deletion src/alire/alire-origins.adb
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,10 @@ package body Alire.Origins is

when VCS_Kinds =>
Table.Set (Keys.URL,
+(Prefixes (This.Kind).all
+((if This.Kind in Git
and then AAA.Strings.Has_Prefix (This.URL, "git@")
then ""
else Prefixes (This.Kind).all)
& (if URI.Scheme (This.URL) in URI.None
-- not needed for remote repos, but for testing
-- ones used locally:
Expand Down
2 changes: 0 additions & 2 deletions src/alire/alire-properties-from_toml.ads
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@ package Alire.Properties.From_TOML is
Crates.External_Shared_Section =>
(Description |
Maintainers |
Maintainers_Logins |
Name => True,
others => False),

Crates.Index_Release =>
(Description |
Maintainers |
Maintainers_Logins |
Name |
Version => True,
others => False),
Expand Down
8 changes: 5 additions & 3 deletions src/alire/alire-properties-labeled.adb
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ package body Alire.Properties.Labeled is
end if;

when Maintainers_Logins =>
if not Utils.Is_Valid_GitHub_Username (L.Value) then
-- The crate may be published through a private index, so we don't
-- know the requirements for a valid username; reject only an
-- empty string.
if L.Value'Length = 0 then
From.Checked_Error
("maintainers-logins must be a valid GitHub login, but got: "
& L.Value);
("maintainers-logins values must be non-empty");
end if;

when Tag =>
Expand Down
2 changes: 1 addition & 1 deletion src/alire/alire-publish-submit.adb
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ package body Alire.Publish.Submit is
Target : constant Absolute_Path
:= Local_Repo_Path
/ VFS.To_Native
(TOML_Index.Manifest_Path (Context.Root.Value.Name))
(TOML_Index.Community_Manifest_Path (Context.Root.Value.Name))
/ Filename;
begin
Directories.Create_Tree (Directories.Parent (Target));
Expand Down
Loading
Loading