Skip to content

Hourly API Sync

Hourly API Sync #42

Workflow file for this run

# MIT License
# Copyright (c) 2026 Darkstone Cloud Platform
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
name: Hourly Java API Sync
on:
schedule:
- cron: '0 * * * *'
workflow_dispatch:
jobs:
check-spec:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
changed: ${{ steps.check_spec.outputs.changed }}
steps:
- uses: actions/checkout@v4
- name: Check for updates
id: check_spec
run: |
curl -s https://api.darkstone.de/v3/api-docs -o current.json
if [ -f openapi-spec.json ] && cmp -s openapi-spec.json current.json; then
echo "No changes found. Aborting."
echo "changed=false" >> $GITHUB_OUTPUT
else
mv current.json openapi-spec.json
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Commit Spec Update
if: steps.check_spec.outputs.changed == 'true'
run: |
git config user.name "bot"
git config user.email "bot@darkstone.de"
git add openapi-spec.json
VERSION="1.0.$(date +%s)"
git commit -m "chore(api): update spec for version $VERSION"
git tag -a "v$VERSION" -m "Release $VERSION"
git push origin main --tags
publish-java:
needs: check-spec
if: needs.check-spec.outputs.changed == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Generate Java SDK (Maven)
run: |
mkdir -p generated/java
# Nutzt openapitools/openapi-generator-cli über das stabile v7.5.0 Tag
docker run --rm -v ${{ github.workspace }}:/local \
-e GENERATOR_CLI_JVM_ARGS="-DapiTests=false -DmodelTests=false -DapiDocs=false -DmodelDocs=false" \
openapitools/openapi-generator-cli:v7.5.0 generate \
-i /local/openapi-spec.json \
-g java \
-o /local/generated/java \
--skip-validate-spec \
--additional-properties=library=native,groupId=de.darkstone,artifactId=cloud-java,invokerPackage=de.darkstone.client,apiPackage=de.darkstone.client.api,modelPackage=de.darkstone.client.model
sudo chown -R $USER:$USER generated/java
- name: Setup Java Environment
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
server-id: github
- name: Publish Java Package via Maven
run: |
cd generated/java
mvn deploy \
-DaltDeploymentRepository=github::default::https://maven.pkg.github.com/${{ github.repository }} \
-Dversion="1.0.${{ github.run_number }}"