Skip to content

Commit 90753b2

Browse files
authored
docs(lux.toml): source templates (#10)
1 parent d1b1b8c commit 90753b2

File tree

3 files changed

+52
-30
lines changed

3 files changed

+52
-30
lines changed

docs/guides/lux-toml.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ for example when [publishing a rock](/guides/publishing).
2929

3030
### `version`
3131

32-
The rock's version (mandatory).
32+
The rock's version (optional).
3333

3434
```toml title="example"
3535
version = "1.0.0"
@@ -49,6 +49,11 @@ However, more complex versions that are not SemVer compliant
4949
(for example ,`1.0-rc1` instead of `1.0.0-rc1`) will be treated as Dev versions,
5050
which cannot be compared with SemVer versions.
5151

52+
If the version is not set in the `lux.toml` and the project is in a git repository,
53+
Lux will search the `HEAD` for a SemVer compliant git tag (with an optional `v` prefix).
54+
If one is found, it will be used to parse the package version.
55+
Otherwise, the version is assumed to be `dev`.
56+
5257
### `description`
5358

5459
Metadata that will be published to luarocks.org (optional).
@@ -67,6 +72,38 @@ maintainer = "neorocks org"
6772
labels = [ "neovim", "tls", "https" ]
6873
```
6974

75+
## Source
76+
77+
To install a remote package, Lux needs to know where to find the source.
78+
This may vary, depending on the package's version.
79+
Unlike a Lua rockspec, Lux provides a mechanism for generating a [published](/guides/publishing)
80+
rockspec's source.
81+
82+
You can declare templates for both SemVer and dev releases:
83+
84+
```toml title="example"
85+
[source]
86+
url = "https://host.com/owner/$(PACKAGE)/archive/refs/tags/$(REF).zip"
87+
dev = "git+https://host.com/owner/$(PACKAGE).git"
88+
```
89+
90+
Or:
91+
92+
```toml title="example"
93+
[source]
94+
url = "https://host.com/owner/$(PACKAGE)/archive/refs/tags/v$(VERSION).zip"
95+
dev = "git+https://host.com/owner/$(PACKAGE).git"
96+
```
97+
98+
When publishing a rock, Lux will perform the following variable substitutions:
99+
100+
- `$(PACKAGE)`: The package name.
101+
- `$(VERSION)`: The package version
102+
(generated from a git tag if not declared in the `lux.toml`).
103+
- `$(REF)`: The git tag or revision
104+
(priority: 1. SemVer tags; 2. tags; 3. revision (commit SHA)).
105+
- You may also specify environment variables with `$(<VAR_NAME>)`.
106+
70107
## Dependencies
71108

72109
Lux differentiates between five types of dependencies:

docs/guides/project-updating.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,6 @@ If you are creating your releases manually, consult your Git forge and see if th
2727
is a "Releases" section from where you can create a new release. If not, create a git tag
2828
named after your release, for example: `2.0.0`.
2929

30-
## Reconfiguring the Source URL
31-
32-
Because the entire repository (including the `lux.toml`) is put under version control,
33-
you can safely prepare the `lux.toml` for the release of a new version.
34-
35-
To prepare a new release, open your project's `lux.toml` and edit the following section:
36-
```diff title="lux.toml"
37-
package = "my-lua-project"
38-
version = "0.1.0"
39-
40-
[source]
41-
url = "git+https://github.com/my-username/my-project"
42-
- tag = "v0.1.0"
43-
+ tag = "v0.2.0"
44-
45-
...
46-
```
47-
48-
:::important
49-
Note the value provided to `tag` - tools like `release-please` automatically prefix the versions
50-
with a `v`. If you made a release manually, then make sure the name is identical to whatever you set.
51-
:::
52-
5330
## Publishing
5431

5532
We're now ready to publish all of our changes to [luarocks.org](https://luarocks.org).

docs/guides/publishing.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ First, you must choose a version number. Lux requires that all projects follow
2525
the [Semantic Versioning](https://semver.org/) specification. If your project is still unstable,
2626
mark it as version `0.1.0`. If your code is ready for general use, mark it as
2727
version `1.0.0`.
28+
Lux can infer the version from a SemVer compliant git tag (with an optional `v` prefix).
29+
In this case, you do not need to declare the version in your `lux.toml`.
2830

2931
There are many ways to keep track of versioning or releases. We recommend a
3032
tool like [release-please](https://github.com/googleapis/release-please), which automatically
@@ -38,27 +40,33 @@ creating a git tag named after a version will also suffice.
3840
## Configuring a Source URL
3941

4042
With the URL in hand, open your project's `lux.toml` and add the following section:
43+
4144
```toml title="lux.toml"
4245
package = "my-lua-project"
4346
version = "0.1.0"
4447

4548
# highlight-start
4649
[source]
47-
url = "git+https://github.com/my-username/my-project"
48-
tag = "v0.1.0"
50+
url = "https://github.com/my-username/my-project/archive/refs/tags/$(REF).zip"
51+
dev = "git+https://github.com/my-username/my-project.git"
4952

5053
# highlight-end
5154

5255
...
5356
```
5457

55-
:::important
56-
We must provide the `git+https://` protocol to instruct Lux to use `git`.
58+
`url` is a template for a SemVer release URL; in this case, a ZIP archive for the release tag.
59+
Note the `$(REF)` variable in the URL template. Lux will substitute it with the tag or revision.
60+
`dev` is a template for a dev release URL, which is a git URL in this example.
61+
62+
:::note
63+
You could also specify `v$(VERSION)` to inject the version instead.
64+
Additionally, you can inject the package name via `$(PACKAGE)`
65+
or any environment variable via `$(VAR_NAME)`.
5766
:::
5867

5968
:::important
60-
Also, note the value we provided to `tag` - tools like `release-please` automatically prefix the versions
61-
with a `v`. If you made a release manually, then make sure the name is identical to whatever you set.
69+
We must provide the `git+https://` protocol in the `dev` URL template to instruct Lux to use `git`.
6270
:::
6371

6472
## Acquiring an API Key

0 commit comments

Comments
 (0)