Java GitHub actions guidelines
What the Action does
In this Action, the package is built and published using Gradle. The package is deployed to the Nexus registry.
Notes
- It's recommended to use a Linux machine for building -
jobs.<name>.runs-on
property. - For setting up Java environment, the action uses actions/setup-java@v1 action.
- It's essential to grant execute permission for
gradlew
withchmod +x gradlew
. - The release is triggered by the
./gradlew publish
command. - Secrets, keys, and tokens are stored in .env variables and secret properties.
GitHub Action example
- Build, test, and publish Java project to Nexus registry
name: Publish package to the Maven Central Repository
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Version release
run: echo Releasing verion $
- name: Publish package
run: ./gradlew publish
env:
RELEASE_TAG: $
NEXUS_USERNAME: $
NEXUS_PASSWORD: $
SIGNING_KEY_ID: $
SIGNING_KEY: $
SIGNING_PASSWORD: $