Publish artifacts to Maven Central #26
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD | |
on: | |
# Push on main excluding tags | |
push: | |
branches: | |
- 'main' | |
tags-ignore: | |
- '*.*' | |
# PR | |
pull_request: | |
branches: | |
- 'main' | |
# When a release is published | |
release: | |
types: [published] | |
# Manual trigger | |
workflow_dispatch: | |
jobs: | |
build: | |
name: CI/CD | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cancel previous runs | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 and gradle cache | |
id: java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'gradle' | |
- name: Check if main repo | |
id: is_main_repo | |
run: | | |
if [ $REPO_NAME == 'openremote/console-android' ]; then | |
echo "value=true" >> $GITHUB_OUTPUT | |
fi | |
env: | |
REPO_NAME: ${{ github.repository }} | |
- name: Run assemble | |
if: ${{ !steps.is_main_repo.outputs.value || github.event_name == 'pull_request' }} | |
run: | | |
gradle assemble | |
- name: Run assemble and publish | |
if: ${{ steps.is_main_repo.outputs.value && github.event_name != 'pull_request' }} | |
run: | | |
echo "$KEYSTORE_BASE64" | base64 -d > keystore | |
command="gradle assemble publishToSonatype closeSonatypeStagingRepository" | |
command="$command -PsigningKey=$MAVEN_SIGNING_KEY -PsigningPassword=$MAVEN_SIGNING_PASSWORD -PpublishUsername=$MAVEN_USERNAME -PpublishPassword=$MAVEN_PASSWORD" | |
command="$command -PkeystoreKeyAlias=$KEYSTORE_KEY_ALIAS -PkeystoreKeyPassword=$KEYSTORE_KEY_PASSWORD -PkeystoreFile=$PWD/keystore -PkeystorePassword=$KEYSTORE_PASSWORD" | |
$command | |
env: | |
EVENT_NAME: ${{ github.event_name }} | |
MAVEN_SIGNING_KEY: ${{ secrets._TEMP_MAVEN_SIGNING_KEY || secrets.MAVEN_SIGNING_KEY }} | |
MAVEN_SIGNING_PASSWORD: ${{ secrets._TEMP_MAVEN_SIGNING_PASSWORD || secrets.MAVEN_SIGNING_PASSWORD }} | |
MAVEN_USERNAME: ${{ secrets._TEMP_MAVEN_USERNAME || secrets.MAVEN_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets._TEMP_MAVEN_PASSWORD || secrets.MAVEN_PASSWORD }} | |
MAVEN_TAG: ${{ github.ref_name }} | |
KEYSTORE_BASE64: | | |
${{ secrets.ANDROID_KEYSTORE_BASE64 }} | |
KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | |
KEYSTORE_KEY_ALIAS: ${{ secrets.ANDROID_KEYSTORE_KEY_ALIAS }} | |
KEYSTORE_KEY_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_KEY_PASSWORD }} | |
- name: Upload build outputs | |
if: success() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-outputs | |
path: | | |
**/build/outputs/**/*.aar | |
**/build/outputs/**/*.apk |