Today we're going to look at how to publish CUBA-application to GitHub Packages using GitHub Actions. There is no rocket science here, but still some nuances
- First of all, an application build on CUBA-platform has a number of modules and a number of build artifacts as a result.
- CUBA uses Gradle as a build-tool and its own plugin
- A Gradle-task to publish artifacts for CUBA is uploadArchives
gradle.build
Let's take a look at gradle.build. According to CUBA-Platform documentation, need to specify uploadRepository for cuba plugin:
cuba { ... uploadRepository { url = 'https://maven.pkg.github.com/OWNER/REPOSITORY' user = System.getenv("GITHUB_ACTOR") password = System.getenv("GITHUB_TOKEN") } }
- url - GitHub Packages artifacts repository for your git-repository.
- user/password - will be taken from environment variables during GitHub Actions workflow execution
GitHub Actions workflow
Next, we'll need to create a directory .github/workflows in the project, where all workflow files in .yaml format are located. They will be automatically picked up by GitHub Actions and executed based on conditions, specified in those files.
Set up the build
In order to create a basic workflow to build your Gradle-project using GitHub Actions, follow the official Docs: Building and testing Java with Gradle
General points:
- Use caching (it's in the Docs)
- I'm using Gradle wrapper (gradlew) to run Gradle tasks and faced issues with access. If so, add the step below before using Gradle in the workflow. Or...grant access to the gradlew file in the repo and push
- name: Grant execute permission for gradlew run: chmod +x gradlew
Publish step
- name: Publish package run: ./gradlew uploadArchives env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
A working demo could be found here: https://github.com/MrArtemAA/cuba-github-packages-publish
Any issues? Drop a comment ;)
Комментарии
Отправить комментарий