Skip to content

Commit c381f89

Browse files
authored
GitHub release tag propagated to artifacts (#82)
* test build gradle with workflow * test for v * simplify, and docs * parse full tag
1 parent c952e0b commit c381f89

File tree

4 files changed

+43
-17
lines changed

4 files changed

+43
-17
lines changed

.github/workflows/release.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
permissions: write-all
1111
runs-on: ubuntu-latest
1212
env:
13-
TAG_NAME: ${{ github.event.inputs.tag }}
13+
FULL_RELEASE_TAG: ${{ github.ref || format('{0}{1}', 'refs/tags/', github.event.release.tag_name) }}
1414
steps:
1515
- name: Checkout sources
1616
uses: actions/checkout@v4
@@ -23,9 +23,13 @@ jobs:
2323
uses: gradle/actions/setup-gradle@v3
2424
with:
2525
gradle-version: 8.5
26+
- name: Extract tag name
27+
run: |
28+
echo "RELEASE_TAG=${FULL_RELEASE_TAG:10}"
29+
echo "RELEASE_TAG=${FULL_RELEASE_TAG:10}" >> $GITHUB_ENV
2630
- name: Build with Gradle
2731
id: build
28-
run: gradle buildReleaseArtifacts
32+
run: gradle -PgithubReleaseTag=${{ env.RELEASE_TAG }} buildReleaseArtifacts
2933
- name: Release
3034
uses: softprops/action-gh-release@v2
3135
with:

build.gradle.kts

+11-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@ group = "com.myDomain"
4141
// - MINOR: Increases when you add new features that are backward-compatible.
4242
// - PATCH: Increases when you make backward-compatible bug fixes.
4343
// You can update these numbers as you release new versions of your library.
44-
version = "1.0.0"
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+
}
4555

4656
// The location of your sketchbook folder. The sketchbook folder holds your installed
4757
// libraries, tools, and modes. It is needed if you:

docs/develop.md

+16-12
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,19 @@ those sections for [resolving dependencies](#resolving-dependencies).
6565
notation. For example, if your website is "myDomain.com", your group ID would be
6666
"com.myDomain". This group id should match the group id discussed in
6767
section [Developing the library](#developing-the-library).
68-
3. **Define the `version` of your library in `build.gradle.kts`.** This value will also be
68+
3. The `sketchbookLocation` is determined programmatically by your operation system, and is
69+
where your Processing `sketchbook` folder is. This folder contains your installed libraries.
70+
It is needed if you:
71+
72+
1. wish to copy the library to the Processing sketchbook, which installs the library locally
73+
2. have Processing library dependencies
74+
75+
This variable is in the editable section, in case the location determined is incorrect. A
76+
symptom of an incorrect `sketchbookLocation` is that your library does not show up as a
77+
contributed library Processing, after being installed. Please look at our
78+
[troubleshooting guide](troubleshooting.md) if you suspect this is the case.
79+
80+
4. **Define the `version` of your library in `build.gradle.kts`.** This value will also be
6981
included in the release artifact `library.properties`. The version of your library usually
7082
follows semantic versioning (semver), which uses three numbers separated by dots:
7183
"MAJOR.MINOR.PATCH" (e.g., "1.0.0").
@@ -76,18 +88,10 @@ those sections for [resolving dependencies](#resolving-dependencies).
7688

7789
You will update these numbers as you release new versions of your library.
7890

79-
4. The `sketchbookLocation` is determined programmatically by your operation system, and is
80-
where your Processing `sketchbook` folder is. This folder contains your installed libraries.
81-
It is needed if you:
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.
8294

83-
1. wish to copy the library to the Processing sketchbook, which installs the library locally
84-
2. have Processing library dependencies
85-
86-
This variable is in the editable section, in case the location determined is incorrect. A
87-
symptom of an incorrect `sketchbookLocation` is that your library does not show up as a
88-
contributed library Processing, after being installed. Please look at our
89-
[troubleshooting guide](troubleshooting.md) if you suspect this is the case.
90-
9195
## Creating examples
9296
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.
9397

docs/release.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,25 @@ Any time you want to update the documentation, edit your `.md` files and `mkdocs
3131
If you prefer not to use the built-in workflow with GitHub Pages and Material for MkDocs, you are free to use another static site generator or hosting service. Note that it’s important that the site remains online, as it serves as a reference for users of your library.
3232

3333
## Releasing on Github
34-
Releasing your library on GitHub allows users to access known-working versions of your library. Unlike the repository itself, which may contain ongoing development or experimental features, releases provide specific versions of your library that are ready for use. Here is how you can make a new release using this template:
34+
[Releasing your library on GitHub](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository)
35+
allows users to access known-working versions of your library. Unlike the repository itself, which may contain ongoing development or experimental features, releases provide specific versions of your library that are ready for use. Here is how you can make a new release using this template:
3536

3637
1. In your repository, click on **Releases**.
3738
2. Click **Draft a new release** to start.
38-
3. Click on **Choose a tag** a tag starting with "v" (e.g., `v1.0.0`). Make sure it matches the version set in your `release.properties` file.
39+
3. Click on **Choose a tag** and type a tag **starting with "v"** (e.g., `v1.0.0`).
3940
4. Select the branch you want to use for this release (e.g., `main`).
4041
5. Add a title and description for the release, highlighting key updates or changes.
4142
6. Click on **Publish release**.
4243

4344
This will trigger the GitHub workflow (`.github/workflows/release.yml`), which automatically create release artifacts—`*.txt`, `*.zip`, `*.pdex` files—and add them to the release.
4445

46+
!!! Important
47+
The release workflow will only trigger if the release tag starts with `v`.
48+
49+
!!! Important
50+
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.
52+
4553
!!! Note
4654
By default, GitHub will also include compressed versions of your source code (e.g., `Source code (zip)` and `Source code (tar.gz)`).
4755

0 commit comments

Comments
 (0)