gurkenlabs / litiengine

LITIENGINE 🕹 The pure 2D java game engine.
https://litiengine.com/
MIT License
731 stars 94 forks source link

Automate maven central publishing #439

Closed steffen-wilke closed 2 years ago

steffen-wilke commented 2 years ago

Right now we publish our library manually from my local machine to Maven Central. This process is tedious and requires repetitive work to be done which also makes it error-prone and it relies on my local setup.

Also, the entire process of publishing the engine is currently described in a private repo which needs to be kept up-to-date. Automating the process would add the process as code which increases reliability.

I recently found this gem that describes how to automate this process with GitHub Actions: How to Sign and Release to The Central Repository with GitHub Actions

In short, we'll need to do the following:

  1. Store the secrets as GitHub secrets
  2. Add a new workflow that runs the publishing process (including the singing of the artifacts)
    • Triggered manually by one of the repository owners
    • Provide an input to set the release = true flag

Additional thoughts This is somewhat related to #438 and #436

steffen-wilke commented 2 years ago

I've added the required secrets to our repository:

weisJ commented 2 years ago

For the gpg key there is an inherent issue with passing it through GitHub actions because it has multiple lines. My solution for this problem was to save the key with # instead of new line characters and replace them in the build script: https://github.com/weisJ/darklaf/blob/378b6f19eae5f5e7b8ac997ea20490c3edd6776d/build.gradle.kts#L213

I’ll adjust #436 to add support publishing to maven central. Probably there should be a separate action for snapshots and releases. Both should probably create a corresponding release + tag in the repo which included the jpackage artifacts.

steffen-wilke commented 2 years ago

Apparently replacing newlines with \n directly also does the trick (see How to Sign and Release to The Central Repository with GitHub Actions).

I did that for the OSSRH_GPG_SECRET_KEY to make it a one-line value.

steffen-wilke commented 2 years ago

@weisJ Since I'm currently fiddling around with this:

The publishing plugin auto-generates tasks based on the PubName (see Maven Publish Plugin Docs), which is something I'm currently struggling with. The actual publish task currently does nothing and right now I'm only able to publish to mavenLocal but there are no tasks for the staging repo.

steffen-wilke commented 2 years ago

@weisJ Thank you very much! The new version has been published to Maven Central.

Do you know whether it's possible to create the Github release just as a draft? We like to provide some more manual info there about the release and what it contains. Triggering a release also notifies followers of the repository but without the adjusted Release Notes ("just" the auto-generated) one.

weisJ commented 2 years ago

Yes simply add draft: true to the action in the workflow :)