forgejo-release.sh: Improve support for different Linux bases #95

Open
Synchro wants to merge 7 commits from Synchro/forgejo-release:distro-agnostic into main
First-time contributor

Currently if you run this action and aren't using a Debian based runner you need to install all tools ahead of time or the Action fails.

Calls to dpkg and apt are replaced with Distro-agnostic equivalents. Additionally the use of which has also been swapped out with command -v for use in environments where which isn't available.
This should improve the behaviour so that it will attempt to install all dependencies on a best effort basis, and at the very least provide some information to the console.

Currently if you run this action and aren't using a Debian based runner you need to install all tools ahead of time or the Action fails. Calls to dpkg and apt are replaced with Distro-agnostic equivalents. Additionally the use of `which` has also been swapped out with `command -v` for use in environments where `which` isn't available. This should improve the behaviour so that it will attempt to install all dependencies on a best effort basis, and at the very least provide some information to the console.
@ -172,0 +191,4 @@
echo "jq and/or curl missing, attempting to install..." >&2
if command -v apt-get >/dev/null 2>&1; then
Contributor

these all need to be tested

these all need to be tested
Author
First-time contributor

I've tested this with all the listed package managers locally and they all work properly.

Do you want me to write a test in CI to do this? Adding a unit test is also something that could be done if wanted.

I've tested this with all the listed package managers locally and they all work properly. Do you want me to write a test in CI to do this? Adding a unit test is also something that could be done if wanted.
Author
First-time contributor

Also: looking at this again, yum is fairly niche and could probably be removed.
I have a version of CentOS 7 that I run locally when an archaic build environment is required.

Also: looking at this again, yum is fairly niche and could probably be removed. I have a version of CentOS 7 that I run locally when an archaic build environment is required.
Contributor

@Synchro wrote in #95 (comment):

Do you want me to write a test in CI to do this? Adding a unit test is also something that could be done if wanted.

Yes, this is what will guard this against future regressions. Untested code, however small and simple, tend to break. And without CI, fixing it will require a contributor to manually re-created the problem which is going to be non trivial.

@Synchro wrote in https://code.forgejo.org/actions/forgejo-release/pulls/95#issuecomment-62570: > Do you want me to write a test in CI to do this? Adding a unit test is also something that could be done if wanted. Yes, this is what will guard this against future regressions. Untested code, however small and simple, tend to break. And without CI, fixing it will require a contributor to manually re-created the problem which is going to be non trivial.
Author
First-time contributor

I'll make some changes to the test.yml workflow. Due to the actions/checkout action being used, images with Node would be required. I will remove everything except the apt and apkinstall lines, the fallback message is an improvement over how it currently functions now.

Testing on Alpine and Debian should be enough; seeing as the release action already assumes you're in a Debian environment.

I'll make some changes to the test.yml workflow. Due to the actions/checkout action being used, images with Node would be required. I will remove everything except the `apt` and `apk`install lines, the fallback message is an improvement over how it currently functions now. Testing on Alpine and Debian should be enough; seeing as the release action already assumes you're in a Debian environment.
Synchro marked this conversation as resolved
Synchro force-pushed distro-agnostic from a91ae74f37
Some checks failed
/ integration (pull_request) Has been cancelled
/ tests (pull_request) Has been cancelled
to 854ee4ce4f
Some checks failed
/ integration (pull_request) Has been cancelled
/ tests (lts-alpine) (pull_request) Has been cancelled
/ tests (lts) (pull_request) Has been cancelled
2025-10-07 08:56:12 +00:00
Compare
Author
First-time contributor

I have updated the tests.yml workflow so that it runs on a Debian and Alpine base image.

If jq and curl aren't found packages will attempt to be installed. On other distros that we can't test for here, an error message is displayed.

I have updated the tests.yml workflow so that it runs on a Debian and Alpine base image. If jq and curl aren't found packages will attempt to be installed. On other distros that we can't test for here, an error message is displayed.
@ -4,1 +6,4 @@
tag: [lts, lts-alpine]
runs-on: docker
container:
image: "node:${{ matrix.tag }}"
Contributor
on: [ pull_request, push ]
jobs:
  tests:
    strategy:
      matrix:
        image: 
          - code.forgejo.org/oci/node:22-trixie
          - code.forgejo.org/oci/node:22-alpine
    runs-on: docker
    container:
      image: ${{ matrix.image }}

Is needed because:

  • hub.docker.io will impose severe rate limiting, using mirrored images avoid that
  • renovate will take care of proposing upgrades when needed. It may not match exactly LTS but it will be in sync with what Forgejo uses

Also lts and lts-alpine are not mirrored at the moment 😁

```yaml on: [ pull_request, push ] jobs: tests: strategy: matrix: image: - code.forgejo.org/oci/node:22-trixie - code.forgejo.org/oci/node:22-alpine runs-on: docker container: image: ${{ matrix.image }} ``` Is needed because: - hub.docker.io will impose severe rate limiting, using mirrored images avoid that - renovate will take care of proposing upgrades when needed. It may not match exactly LTS but it will be in sync with what Forgejo uses Also lts and lts-alpine are not mirrored at the moment 😁
Author
First-time contributor

Sweet that makes things easy 😄

Didn't realise you guys had local mirrors, I'll swap those out and then hopefully all is good.

Sweet that makes things easy 😄 Didn't realise you guys had local mirrors, I'll swap those out and then hopefully all is good.
Author
First-time contributor

This should be in place now as of 1d79e86315

Let me know if anything else needs to be adjusted.

This should be in place now as of https://code.forgejo.org/actions/forgejo-release/commit/1d79e86315db6951e9ea35afd461f8bce5a1fd62 Let me know if anything else needs to be adjusted.
Synchro marked this conversation as resolved
Synchro force-pushed distro-agnostic from 854ee4ce4f
Some checks failed
/ integration (pull_request) Has been cancelled
/ tests (lts-alpine) (pull_request) Has been cancelled
/ tests (lts) (pull_request) Has been cancelled
to 1d79e86315
Some checks failed
/ tests (code.forgejo.org/oci/node:22-trixie) (pull_request) Successful in 38s
/ tests (code.forgejo.org/oci/node:22-alpine) (pull_request) Failing after 6s
/ integration (pull_request) Successful in 19m51s
2025-10-07 20:54:51 +00:00
Compare
Contributor
https://code.forgejo.org/actions/forgejo-release/actions/runs/846/jobs/0/attempt/2 the checkout action fails on 22-alpine 🤔
Contributor

you need to install bash for alpline before running the tests, that's why it fails

you need to install bash for alpline before running the tests, that's why it fails
Contributor

@earl-warren wrote in #95 (comment):

https://code.forgejo.org/actions/forgejo-release/actions/runs/846/jobs/0/attempt/2

the checkout action fails on 22-alpine 🤔

It works, it is bash missing, of course. It is worth a mention in the action.yml / README

@earl-warren wrote in https://code.forgejo.org/actions/forgejo-release/pulls/95#issuecomment-62751: > https://code.forgejo.org/actions/forgejo-release/actions/runs/846/jobs/0/attempt/2 > > the checkout action fails on 22-alpine :thinking: It works, it is bash missing, of course. It is worth a mention in the action.yml / README
Author
First-time contributor

@earl-warren wrote in #95 (comment):

@earl-warren wrote in #95 (comment):

https://code.forgejo.org/actions/forgejo-release/actions/runs/846/jobs/0/attempt/2
the checkout action fails on 22-alpine 🤔

It works, it is bash missing, of course. It is worth a mention in the action.yml / README

Ah that's a good point. Do you have any issues with dropping some bash-isms in the script(s) and using POSIX sh instead?

Functionality should be identical, just some minor syntax adjustments should be needed. That should solve any issues for images that lack bash

@earl-warren wrote in https://code.forgejo.org/actions/forgejo-release/pulls/95#issuecomment-62762: > @earl-warren wrote in #95 (comment): > > > https://code.forgejo.org/actions/forgejo-release/actions/runs/846/jobs/0/attempt/2 > > the checkout action fails on 22-alpine :thinking: > > It works, it is bash missing, of course. It is worth a mention in the action.yml / README Ah that's a good point. Do you have any issues with dropping some bash-isms in the script(s) and using POSIX sh instead? Functionality should be identical, just some minor syntax adjustments should be needed. That should solve any issues for images that lack `bash`
Refactor bash-isms and use POSIX sh where applicable
Some checks failed
/ tests (code.forgejo.org/oci/node:22-alpine) (pull_request) Failing after 10s
/ tests (code.forgejo.org/oci/node:22-trixie) (pull_request) Successful in 12s
/ integration (pull_request) Successful in 17m48s
324005b6c0
forgejo-release.sh: Handle dependency globally
Some checks failed
/ tests (code.forgejo.org/oci/node:22-alpine) (pull_request) Failing after 10s
/ tests (code.forgejo.org/oci/node:22-trixie) (pull_request) Successful in 15s
/ integration (pull_request) Successful in 17m56s
8cfa95b448
This ensures checks are consistent  where needed. setup_api was retained in case of changes that might need to be made in the future.
forgejo-release.sh: Allow arguments to be checked in check_dependencies
Some checks failed
/ tests (code.forgejo.org/oci/node:22-alpine) (pull_request) Failing after 12s
/ tests (code.forgejo.org/oci/node:22-trixie) (pull_request) Successful in 14s
/ integration (pull_request) Successful in 18m24s
fc4e870d23
This allows us to pass in extra dependencies in testing scenarios. In this case sign_release requires gpg to run.
forgejo-release.sh: gpg-agent is also required for signing releases.
All checks were successful
/ tests (code.forgejo.org/oci/node:22-alpine) (pull_request) Successful in 13s
/ tests (code.forgejo.org/oci/node:22-trixie) (pull_request) Successful in 14s
/ integration (pull_request) Successful in 18m30s
603d197551
Author
First-time contributor

Okay, it looks like I have everything working according to the tests!

Let me know if you'd like any changes to the implementation, or if there is anything new that needs to be added to the integration.yml workflow.

Okay, it looks like I have everything working according to the tests! Let me know if you'd like any changes to the implementation, or if there is anything new that needs to be added to the `integration.yml` workflow.
mahlzahn requested changes 2025-10-09 22:35:54 +00:00
Dismissed
@ -4,0 +4,4 @@
strategy:
matrix:
image:
- code.forgejo.org/oci/node:22-trixie
First-time contributor

not data.forgejo.org? @earl-warren ?

not data.forgejo.org? @earl-warren ?
Contributor

that's ok for now, it lands on code.forgejo.org anyways. Only actions are on a separate server.

that's ok for now, it lands on code.forgejo.org anyways. Only actions are on a separate server.
Synchro marked this conversation as resolved
@ -29,0 +43,4 @@
}
check_dependencies() {
# Always required for API parsing and downloads
First-time contributor

Concerning my comment below, don’t check always for these default deps, but make them all extra arguments.

Concerning my comment below, don’t check always for these default deps, but make them all extra arguments.
Author
First-time contributor

Good point! I was tempted to go that route initially and I guess I should have in hindsight 😄

I can make that adjustment, setup_api can pass in curl and jq as arguments. One limitation that might be good to adjust in the future when it becomes a problem is that the binary names that are searched for with command -v may not match the package name.

As of now however it seems like the package name matches the binaries that they provide (for the packages that this action needs)

Good point! I was tempted to go that route initially and I guess I should have in hindsight 😄 I can make that adjustment, setup_api can pass in curl and jq as arguments. One limitation that might be good to adjust in the future when it becomes a problem is that the binary names that are searched for with `command -v` may not match the package name. As of now however it seems like the package name matches the binaries that they provide (for the packages that this action needs)
Author
First-time contributor
Fixed with https://code.forgejo.org/actions/forgejo-release/pulls/95/commits/5d73a41e6aa01cec0ff1401740ecec68edd854d2
Synchro marked this conversation as resolved
@ -128,3 +175,2 @@
sign_release() {
local passphrase
if test -s "$GPG_PASSPHRASE"; then
check_dependencies gpg gpg-agent
First-time contributor

After this latest edit it seems to me that check_dependencies should always be called with input arguments, e.g., sign_release does not need jq and curl.

After this latest edit it seems to me that `check_dependencies` should always be called with input arguments, e.g., `sign_release` does not need jq and curl.
Author
First-time contributor
Fixed with https://code.forgejo.org/actions/forgejo-release/pulls/95/commits/5d73a41e6aa01cec0ff1401740ecec68edd854d2
Synchro marked this conversation as resolved
First-time contributor

@Synchro wrote in #95 (comment):

Ah that's a good point. Do you have any issues with dropping some bash-isms in the script(s) and using POSIX sh instead?

Functionality should be identical, just some minor syntax adjustments should be needed. That should solve any issues for images that lack bash

Looks good, in my opinion!

@Synchro wrote in https://code.forgejo.org/actions/forgejo-release/pulls/95#issuecomment-62801: > Ah that's a good point. Do you have any issues with dropping some bash-isms in the script(s) and using POSIX sh instead? > > Functionality should be identical, just some minor syntax adjustments should be needed. That should solve any issues for images that lack `bash` Looks good, in my opinion!
@ -4,0 +5,4 @@
matrix:
image:
- code.forgejo.org/oci/node:22-trixie
- code.forgejo.org/oci/node:22-alpine
First-time contributor

why not node:24?

why not `node:24`?
Author
First-time contributor

This was to make sure that the LTS release is targeted, there is no LTS tag that is mirrored.

See below for context:
#95 (comment)

This was to make sure that the LTS release is targeted, there is no `LTS` tag that is mirrored. See below for context: https://code.forgejo.org/actions/forgejo-release/pulls/95#issuecomment-62669
First-time contributor

OK, thanks for the explanation.
@earl-warren Why can't I resolve threads here?

OK, thanks for the explanation. @earl-warren Why can't I resolve threads here?
Synchro marked this conversation as resolved
forgejo-release.sh: check_dependencies should only act on passed arguments.
All checks were successful
/ tests (code.forgejo.org/oci/node:22-trixie) (pull_request) Successful in 9s
/ tests (code.forgejo.org/oci/node:22-alpine) (pull_request) Successful in 12s
/ integration (pull_request) Successful in 17m48s
5d73a41e6a
Removed the default curl and jq option, and passed it in when needed.
mahlzahn approved these changes 2025-10-10 07:39:01 +00:00
Contributor

that changes the scope of the pull request significantly. It is excellent the tests pass but it will take time to review it thoroughly.

Could you split this refactor in a different pull request? It is fine with me on principle.

that changes the scope of the pull request significantly. It is excellent the tests pass but it will take time to review it thoroughly. Could you split this refactor in a different pull request? It is fine with me on principle.
First-time contributor

@earl-warren wrote in #95 (comment):

that changes the scope of the pull request significantly. It is excellent the tests pass but it will take time to review it thoroughly.

Could you split this refactor in a different pull request? It is fine with me on principle.

I found reviewing via the new single-commit review with split view pleasant for this PR. But, up to you to decide.

@earl-warren wrote in https://code.forgejo.org/actions/forgejo-release/pulls/95#issuecomment-62983: > that changes the scope of the pull request significantly. It is excellent the tests pass but it will take time to review it thoroughly. > > Could you split this refactor in a different pull request? It is fine with me on principle. I found reviewing via the new single-commit review with split view pleasant for this PR. But, up to you to decide.
Contributor

I agree this pull request is very pleasant to work with. There are two very different topics (refactor + alpine support) and I do prefer they are in two separate pull requests to help with discovery in the future.

I agree this pull request is very pleasant to work with. There are two very different topics (refactor + alpine support) and I do prefer they are in two separate pull requests to help with discovery in the future.
Author
First-time contributor

Apologies I got swamped with work, so just got to looking at this now.

I can go ahead and split this PR into two parts, but in order for Alpine support to function correctly without first installing bash the refactor is also needed. It feels a bit weird to require bash for this PR when in reality a minor refactor is needed to avoid it entirely.

If I do split this PR in two parts the testing will fail when run on an Alpine container. So I can either disable Alpine tests or omit it from this PR entirely or I can rephrase this PR to be a POSIX sh refactor + improvements to dependency checking.

If reordering the commits is what you'd like to make it easier to review (or make more sense overall) let me know.

The refactor only really does some minor syntax changes (dealing with arrays, debugging adjustments) other functionality is untouched.

Apologies I got swamped with work, so just got to looking at this now. I can go ahead and split this PR into two parts, but in order for Alpine support to function correctly without first installing bash the refactor is also needed. It feels a bit weird to require bash for this PR when in reality a minor refactor is needed to avoid it entirely. If I do split this PR in two parts the testing will fail when run on an Alpine container. So I can either disable Alpine tests or omit it from this PR entirely or I can rephrase this PR to be a POSIX sh refactor + improvements to dependency checking. If reordering the commits is what you'd like to make it easier to review (or make more sense overall) let me know. The refactor only really does some minor syntax changes (dealing with arrays, debugging adjustments) other functionality is untouched.
@ -29,0 +63,4 @@
return 1
fi
fi
}
Contributor

I would also add dnf and pacman. Do note that this will not work on bare-metal (dockerless) runners.

I would also add `dnf` and `pacman`. Do note that this will not work on bare-metal (dockerless) runners.
Some checks are pending
/ tests (code.forgejo.org/oci/node:22-trixie) (pull_request) Successful in 9s
/ tests (code.forgejo.org/oci/node:22-alpine) (pull_request) Successful in 12s
/ integration (pull_request) Successful in 17m48s
Required
Details
/ tests (pull_request)
Required
This pull request has changes conflicting with the target branch.
  • .forgejo/workflows/tests.yml
  • forgejo-release.sh
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u distro-agnostic:Synchro-distro-agnostic
git switch Synchro-distro-agnostic
Sign in to join this conversation.
No milestone
No project
No assignees
4 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!95
No description provided.