Skip to content

Remove config override directory functionality (#5) #4

Remove config override directory functionality (#5)

Remove config override directory functionality (#5) #4

Workflow file for this run

name: Publish to Maven Central
on:
push:
branches: [ "main" ]
jobs:
publish:
runs-on: ubuntu-latest
if: github.repository == 'ReforgeHQ/sdk-java'
steps:
- name: "Checkout"
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Extract version from pom.xml
id: extract_version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Current version: $VERSION"
- name: Check if version exists in Maven Central
id: version_check
run: |
VERSION=${{ steps.extract_version.outputs.version }}
echo "Checking if version $VERSION exists in Maven Central..."
# Check if version exists (non-snapshot versions only)
if [[ "$VERSION" != *-SNAPSHOT ]]; then
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://repo1.maven.org/maven2/com/reforge/sdk-parent/$VERSION/sdk-parent-$VERSION.pom")
if [ "$HTTP_STATUS" = "200" ]; then
echo "Version $VERSION already exists in Maven Central"
echo "should_publish=false" >> $GITHUB_OUTPUT
else
echo "Version $VERSION does not exist in Maven Central"
echo "should_publish=true" >> $GITHUB_OUTPUT
fi
else
echo "Snapshot version detected, skipping publication"
echo "should_publish=false" >> $GITHUB_OUTPUT
fi
- name: Import GPG key
if: steps.version_check.outputs.should_publish == 'true'
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Configure Maven settings
if: steps.version_check.outputs.should_publish == 'true'
uses: whelk-io/maven-settings-xml-action@v20
with:
repositories: |
[
{
"id": "ossrh",
"url": "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
]
servers: |
[
{
"id": "ossrh",
"username": "${{ secrets.OSSRH_USERNAME }}",
"password": "${{ secrets.OSSRH_TOKEN }}"
}
]
- name: Publish to Maven Central
if: steps.version_check.outputs.should_publish == 'true'
run: |
echo "Publishing version ${{ steps.extract_version.outputs.version }} to Maven Central..."
mvn clean deploy -P release --no-transfer-progress
env:
REFORGE_INTEGRATION_TEST_SDK_KEY: ${{ secrets.REFORGE_INTEGRATION_TEST_SDK_KEY }}
REFORGE_SDK_KEY: 1-fake-apikey
REFORGE_INTEGRATION_TEST_ENCRYPTION_KEY: "c87ba22d8662282abe8a0e4651327b579cb64a454ab0f4c170b45b15f049a221"
PREFAB_INTEGRATION_TEST_ENCRYPTION_KEY: "c87ba22d8662282abe8a0e4651327b579cb64a454ab0f4c170b45b15f049a221"
NOT_A_NUMBER: "not a number"
IS_A_NUMBER: 1234
- name: Create GitHub Release
if: steps.version_check.outputs.should_publish == 'true'
uses: ncipollo/create-release@v1
with:
tag: "v${{ steps.extract_version.outputs.version }}"
name: "Release v${{ steps.extract_version.outputs.version }}"
generateReleaseNotes: true
draft: false
prerelease: ${{ contains(steps.extract_version.outputs.version, 'RC') || contains(steps.extract_version.outputs.version, 'beta') || contains(steps.extract_version.outputs.version, 'alpha') }}