Skip to content

Commit 76400b4

Browse files
authored
define version in properties file (#84)
* move definition of prettyVersion * update docs * add comment about overwrite with release tag
1 parent c381f89 commit 76400b4

File tree

4 files changed

+40
-48
lines changed

4 files changed

+40
-48
lines changed

Diff for: build.gradle.kts

+15-25
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ java {
1818
}
1919
}
2020

21+
// read in user-defined properties in release.properties file
22+
// most of these properties will be saved to the library.properties file, a required file in the release
23+
// using task writeLibraryProperties
24+
val libraryProperties = Properties().apply {
25+
load(rootProject.file("release.properties").inputStream())
26+
}
27+
28+
// the following conditional allows for the version to be overwritten by a Github release
29+
// via the release workflow, which defines a property named "githubReleaseTag"
30+
version = if (project.hasProperty("githubReleaseTag")) {
31+
// remove leading "v" from tag (the leading "v" is required for the release workflow to trigger)
32+
project.property("githubReleaseTag").toString().drop(1)
33+
} else {
34+
libraryProperties.getProperty("prettyVersion")
35+
}
2136

2237
//==========================
2338
// USER BUILD CONFIGURATIONS
@@ -35,24 +50,6 @@ val libName = "myLibrary"
3550
// Replace "com.myDomain" with your own domain or organization name.
3651
group = "com.myDomain"
3752

38-
// The version of your library. It usually follows semantic versioning (semver),
39-
// which uses three numbers separated by dots: "MAJOR.MINOR.PATCH" (e.g., "1.0.0").
40-
// - MAJOR: Increases when you make incompatible changes.
41-
// - MINOR: Increases when you add new features that are backward-compatible.
42-
// - PATCH: Increases when you make backward-compatible bug fixes.
43-
// You can update these numbers as you release new versions of your library.
44-
45-
// the following conditional allows for the version to be overwritten by a Github release
46-
// via the release workflow, which defines a property named "githubReleaseTag"
47-
48-
version = if (project.hasProperty("githubReleaseTag")) {
49-
// remove leading "v" from tag (the leading "v" is required for the release workflow to trigger)
50-
project.property("githubReleaseTag").toString().drop(1)
51-
52-
} else {
53-
"1.0.0"
54-
}
55-
5653
// The location of your sketchbook folder. The sketchbook folder holds your installed
5754
// libraries, tools, and modes. It is needed if you:
5855
// 1. wish to copy the library to the Processing sketchbook, which installs the library locally
@@ -149,13 +146,6 @@ val releaseRoot = "$rootDir/release"
149146
val releaseName = libName
150147
val releaseDirectory = "$releaseRoot/$releaseName"
151148

152-
// read in user-defined properties in release.properties file
153-
// to be saved in library.properties file, a required file in the release
154-
// using task writeLibraryProperties
155-
val libraryProperties = Properties().apply {
156-
load(rootProject.file("release.properties").inputStream())
157-
}
158-
159149
tasks.register<WriteProperties>("writeLibraryProperties") {
160150
group = "processing"
161151
destinationFile = project.file("library.properties")

Diff for: docs/develop.md

+12-22
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,6 @@ those sections for [resolving dependencies](#resolving-dependencies).
7777
contributed library Processing, after being installed. Please look at our
7878
[troubleshooting guide](troubleshooting.md) if you suspect this is the case.
7979

80-
4. **Define the `version` of your library in `build.gradle.kts`.** This value will also be
81-
included in the release artifact `library.properties`. The version of your library usually
82-
follows semantic versioning (semver), which uses three numbers separated by dots:
83-
"MAJOR.MINOR.PATCH" (e.g., "1.0.0").
84-
85-
- MAJOR: Increases when you make incompatible changes.
86-
- MINOR: Increases when you add new features that are backward-compatible.
87-
- PATCH: Increases when you make backward-compatible bug fixes.
88-
89-
You will update these numbers as you release new versions of your library.
90-
91-
!!! Note
92-
If you [release your library on Github](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository),
93-
the prettyVersion field in your release artifacts will reflect your release tag instead of the `version` defined in `build.gradle.kts`, as a helpful automation.
9480

9581
## Creating examples
9682
Examples help users understand your library’s functionality, it is recommended that you include several clear and well-commented samples sketches in the `examples` folder.
@@ -99,16 +85,13 @@ Examples help users understand your library’s functionality, it is recommended
9985
The example sketch included in this template outputs the image shown on the home page.
10086

10187
## Creating the release artifacts
102-
If you've already gone through the [Getting started](getting-started.md#first-steps) guide, you will have
103-
already run Gradle tasks, and edited the `release.properties` file.
10488

105-
1. Fill in the file `release.properties` with information for your library. This information will be
106-
used by Gradle to create the `library.properties` file, which is one of the required release
107-
artifacts, used by the website and Contribution Manager to describe your library. In the file itself,
108-
There are comments to guide you. To create just the `library.properties` file without building the
89+
1. Fill in the file `release.properties` with information for your library. In the file itself,
90+
There are comments to guide you. This information will be used by Gradle to create the
91+
`library.properties` file, which is one of the required release artifacts, used by the website
92+
and Contribution Manager to describe your library. To create just the `library.properties` file without building the
10993
library, toggle `Tasks` > `processing` and double click `writeLibraryProperties`. This task will
110-
copy all the values in `release.properties`, and also include the `version` in your `build.gradle.kts`
111-
file as `prettyVersion`.
94+
copy all the values in `release.properties`.
11295
2. **To build the library and create the release artifacts, run the Gradle task `buildReleaseArtifacts`.**
11396
This task will create a `release` folder with needed artifacts. To do this, go to the Gradle menu
11497
(elephant), toggle `Tasks` > `processing` and double click `buildReleaseArtifacts`. This task
@@ -124,6 +107,13 @@ already run Gradle tasks, and edited the `release.properties` file.
124107
`deployToProcessingSketchbook`, which will create the release artifacts, and copy them into the
125108
sketchbook folder.
126109

110+
111+
!!! Note
112+
If you [release your library on Github](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository),
113+
your release tag will be used for the value of the `prettyVersion` field, overwriting the value for `prettyVersion`
114+
defined in `release.properties`, as a helpful automation.
115+
116+
127117
## Additional Documentation
128118

129119
See the following guides for more details:

Diff for: docs/release.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This will trigger the GitHub workflow (`.github/workflows/release.yml`), which a
4848

4949
!!! Important
5050
The release tag created on Github will be propagated to the release artifacts.
51-
Specifically the tag, without the leading `v`, will be used for the `prettyVersion` in the txt file and `library.properties` file in the zip. This overwrites the value input for `version` in the `build.gradle.kts` file.
51+
Specifically the tag, without the leading `v`, will be used for the `prettyVersion` in the txt file and `library.properties` file in the zip. This overwrites the value input for `prettyVersion` in the `release.properties` file.
5252

5353
!!! Note
5454
By default, GitHub will also include compressed versions of your source code (e.g., `Source code (zip)` and `Source code (tar.gz)`).

Diff for: release.properties

+12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ name=A Template Example Library
1010
# releases you've had. NOTE: This must be parsable as an int!
1111
version=1
1212

13+
# The version of your library. It usually follows semantic versioning (semver),
14+
# which uses three numbers separated by dots: "MAJOR.MINOR.PATCH" (e.g., "1.0.0").
15+
# - MAJOR: Increases when you make incompatible changes.
16+
# - MINOR: Increases when you add new features that are backward-compatible.
17+
# - PATCH: Increases when you make backward-compatible bug fixes.
18+
# You can update these numbers as you release new versions of your library.
19+
#
20+
# Note: The prettyVersion value defined here can be overwritten by a GitHub release tag.
21+
# If a release tag is present, the numeric part of the tag will be used as the version number.
22+
# See docs/release.md for more details.
23+
prettyVersion = 1.0.0
24+
1325
# List of authors. Links can be provided using the syntax [author name](url).
1426
authors=[Your Name](https://myDomain.com)
1527

0 commit comments

Comments
 (0)