Make release-dir optional #54

Open
opened 2025-06-04 10:54:52 +00:00 by wetneb · 2 comments

If I want to publish a release without any artifacts added to it, it would be nice if release-dir could be optional.
At the moment my workaround is to create a release_dir directory with an empty file in it, and pass that to the action, which has the downside of adding an empty file as the release artifact.

If I want to publish a release without any artifacts added to it, it would be nice if release-dir could be optional. At the moment my workaround is to create a `release_dir` directory with an empty file in it, and pass that to the action, which has the downside of adding an empty file as the release artifact.
Contributor

@wetneb, maybe I am missing something, but I have been using actions/forgejo-release@v2 for a long time now without release_dir specified and it works exactly as one would expect (release creation without any files being added)

@wetneb, maybe I am missing something, but I have been using `actions/forgejo-release@v2` for a long time now without `release_dir` specified and it works exactly as one would expect (release creation without any files being added)

I can confirm that the path set in release-dir must exist and contain a file. If it does not, this loop in L87-L89 of forgejo-release.sh

for file in "$RELEASE_DIR"/*; do
    assets=("${assets[@]}" -a "$file")
done

will expand the glob to a literal *:

assets=('-a' 'dist/release/*')

which in turn results in

Error: open dist/release/*: no such file or directory

when tea create is called. You can find an example job of the failure here: https://codeberg.org/janw/podcast-archiver/actions/runs/153#jobstep-3-1

To prevent * expanding to a literal of itself, bash has the nullglob option:

If set, filename expansion patterns which match no files (see Filename Expansion) expand to nothing and are removed, rather than expanding to themselves.

Activating it around the section, will prevent the issue, and make release-dir truly optional:

shopt -s nullglob
for file in "$RELEASE_DIR"/*; do
    assets=("${assets[@]}" -a "$file")
done
shopt -u nullglob

Note: this issue also applies to the loop in the sign_release function.

Edit: I opened a PR with a fix: #87 🙂

I can confirm that the path set in `release-dir` must exist and contain a file. If it does not, this loop [in L87-L89 of forgejo-release.sh](https://code.forgejo.org/actions/forgejo-release/src/commit/9223b9c0d5e08994ec567e9263f4321a3993b379/forgejo-release.sh#L87-L89) ```sh for file in "$RELEASE_DIR"/*; do assets=("${assets[@]}" -a "$file") done ``` will expand the glob to a literal `*`: ```sh assets=('-a' 'dist/release/*') ``` which in turn results in > Error: open dist/release/*: no such file or directory when `tea create` is called. You can find an example job of the failure here: https://codeberg.org/janw/podcast-archiver/actions/runs/153#jobstep-3-1 To prevent `*` expanding to a literal of itself, bash has the `nullglob` option: > [If set, filename expansion patterns which match no files (see Filename Expansion) expand to nothing and are removed, rather than expanding to themselves.](https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html) Activating it around the section, will prevent the issue, and make `release-dir` truly optional: ```sh shopt -s nullglob for file in "$RELEASE_DIR"/*; do assets=("${assets[@]}" -a "$file") done shopt -u nullglob ``` Note: this issue also applies to the loop in the `sign_release` function. Edit: I opened a PR with a fix: #87 🙂
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
actions/forgejo-release#54
No description provided.