Could anyone please tell me why my gradle build ac...
# community-support
d
Could anyone please tell me why my gradle build action doesn’t seem to work every time the GitHub action runs? The commands work perfectly without failing when I run them locally, but they fail as soon as the GitHub action runs them. I read online that it is usually due to a file structure issue that an error like this one would occur. I am very new to this, so let me know if there is an issue with my file structure. Failing Action Log: https://github.com/DylanDevelops/SimpleShapesLibrary/actions/runs/8257184525/job/22587269168#logs GitHub Repo: https://github.com/DylanDevelops/SimpleShapesLibrary GitHub Action File: https://github.com/DylanDevelops/SimpleShapesLibrary/blob/main/.github/workflows/gradle-publish.yml
v
You already fixed the problem it seems.
In the failing build you sent the link of, there is simply one of the 4 wrapper files missing, the actual JAR file that contains the class. So of course it tells you that it cannot find the class. 🙂
d
@Vampire I just ran it again and the build failed? https://github.com/DylanDevelops/SimpleShapesLibrary/actions/runs/8412409233
v
Sure, why should rerunning fix it?
It is the same broken state as of 2 weeks ago where the file is missing
You fixed it after that on
main
d
ohhh so i need to create a brand new release on a new tag?
v
As the state in that tag is broken, ...
d
Ahhhhhh that was such a silly mistake. i was remaking the release but not removing the previous tag
ill keep working and let you know if i have any other issues
👌 1
@Vampire Okay now I’m getting a new error when publishing. Is it an issue with my file structure do you know? https://github.com/DylanDevelops/SimpleShapesLibrary/actions/runs/8412601141
v
Why should it? Even for the first there was no reason to assume anything with file structure.
The server says, you send bullshit and doesn't like it.
Is the 0.1.0 release maybe still present there?
GitHub packages most likely does not allow re-publish of the same version without deleting the old one first
d
Where do I check if there is an already exisiting package?
i havent gotten a publish success message yet so I dont know how it would be published. but im also new to github packages and java gradle so i wouldnt know
v
In the GitHub Packages I guess?
Never used that non-sense
d
I see this
Could it be an issue with the tag being called v0.1.0 but the version in build.gradle being 0.1.0 without the v
v
As I said, I never used that non-sense service, so I don't know
But I highly doubt it
The published package should have nothing to do with the tag of the code
You probably need to read the documentation to find out what the requirements are
👍 1
If you wonder why I call that service non-sense, it is because even after years of operation and complaints, they were not able to implement anonymous access. So noone can use your packages unless they authenticate with a GitHub account's token.
So for private things it might be fine, but totally useless for public releases
d
Is there an alternative? can i publish using github actions without using their packages solution
v
Btw. before asking in any community you should at least try to google. First hit for gpr and 422 tells you that your artifact name needs to be all lowercase which is not the case for you.
Is there an alternative?
Sure, plenty. But the only choice you should take is publishing to Maven Central. It is the canonical repository for Maven builds and practically any Gradle build out there also has it as repository already.
can i publish using github actions without using their packages solution
You can publish to any service you like.
d
Hey @Vampire! I’m using sonatype now, which I think is the right place for maven central. However, now I’m getting an error when building. Would you mind double checking my build.gradle file if you have time? https://github.com/DylanDevelops/SimpleShapesLibrary/actions/runs/8427692742
Thanks for all your help so far!
v
Yes, OSSRH is the way to Maven Central
Which part of the error is unclear?
Received status code 401 from server: Unauthorized
So you missed to supply or supplied wrong credentials
Btw. when publishing to OSSRH, I recommend you use the https://github.com/gradle-nexus/publish-plugin plugin
d
Sweet I’ll look into this plugin
v
It works-around some quirks and also allows you to fully automate the publishing wihtout the need to open the web ui
d
@Vampire I’m struggling to get my thing to work 😞
I created the name space and everything like that but I’m not sure if there is something that I’m doing incorrecrly in the code
v
As it said "Could not read PGP secret key", you most probably did something wrong, yes. Maybe your
SIGNING_KEY
secret is not formatted correctly. Btw. afair you should also not define the publishing repo twice like you do right now.
d
@Vampire What do you mean defining it twice?
d
would I want to keep the nexusPubluishing one?
@Vampire Okay so i just successfully built and published for the first time with the action (it succeeded with no error) but now there is no version of my thing on the website?
v
Which website?
First publish might need a little bit as they do a small one-time review afair. Also the search index does not update immediately. Also, if you just run
publish
, you just uploaded the artifacts to the staging repository, but you need to close and release it, which you can do also with Gradle task with the plugin I recommended, as said before. If you don't use those, you need to do it on the web interface of OSSRH as documented there.
d
@Vampire this is the website: https://central.sonatype.com/
v
Yeah, thought so. So what I wrote above.
d
Okay I updated my workflow file but its still failing. I also was told that adding the third party plugin needed to be defined in a build.gradle that existed in the root. so I created another build.gradle in the root but I’m not sure if that is what I’m supposed to do. One is in the root and one is in the SimpleShapesLibrary folder
@Vampire If you are able to take a look and see if I’m doing it right that would be perfect
v
Maybe you should read the documentation of the plugin you try to use, because you are not following it
d
@Vampire Am I doing the build.gradle thing correctly like creating another one? I’ll dig deeper into the plugin documentation its just gradle I’m really new to.
v
The plugin docs say you need to apply it to the root project, so yes, that part was correct
But it also says "It is important to set the group and the version to the root project"
Maybe there is more missing 🤷‍♂️
And it's probably a very bad idea to name the root project the same as a subproject
And you probably need to move the
nexusPublishing
block to the root project too, but if in doubt, ask the maintainer of that plugin
I never used it in a multi-project build
d
@Vampire yeah i appreciate all your help
i am incredibly new to this so really the only thing i kinda understand is java
but all the structuring stuff is all new to me too
v
Don't worry, you'll get more familiar with it