Add addon rest-api
#35
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
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors | |
# SPDX-License-Identifier: CC0-1.0 | |
name: Build addons | |
on: | |
pull_request: | |
push: | |
branches: ["main"] | |
tags: ["v*.*.*"] | |
env: | |
registry: ghcr.io/dsd-dbs/capella-addons/ | |
addons: rest-api | |
JVM_DIR: /usr/lib/jvm | |
jobs: | |
# test: | |
# name: Test | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Test | |
# run: |- | |
quality: | |
name: Ensure code quality | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install pre-commit | |
run: |- | |
python -m pip install pre-commit | |
- name: Run pre-commit | |
run: |- | |
pre-commit run --all-files | |
build-addons: | |
strategy: | |
matrix: | |
capella: | |
- version: "6.0.0" | |
jdk: | |
name: "jdk-17.0.6+10" | |
url: "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.6%2B10/OpenJDK17U-jdk_aarch64_linux_hotspot_17.0.6_10.tar.gz" | |
# url: "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.6%2B10/OpenJDK17U-jdk_x64_linux_hotspot_17.0.6_10.tar.gz" | |
# - version: "6.1.0" | |
# jdk: | |
# name: "jdk-17.0.6+10" | |
# url: "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.6%2B10/OpenJDK17U-jdk_aarch64_linux_hotspot_17.0.6_10.tar.gz" | |
# - version: "7.0.0" | |
# jdk: | |
# name: "jdk-17.0.11+9" | |
# url: "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.11%2B9/OpenJDK17U-jdk_x64_linux_hotspot_17.0.11_9.tar.gz" | |
addon: | |
- rest-api | |
name: Setup build environment for Capella ${{ matrix.capella.version }} and build addon ${{ matrix.addon }} | |
needs: [quality] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install Capella from capelladocker-images | |
run: |- | |
docker pull ghcr.io/dsd-dbs/capella-dockerimages/capella/remote:${{ matrix.capella.version }}-selected-dropins-main | |
if [ ! -d /tmp/capella_${{ matrix.capella.version }} ]; then | |
docker run --rm -v /tmp:/tmp --entrypoint="" --user=root \ | |
ghcr.io/dsd-dbs/capella-dockerimages/capella/remote:${{ matrix.capella.version }}-selected-dropins-main \ | |
bash -c "cp -r /opt/capella /tmp/capella_${{ matrix.capella.version }}" | |
fi | |
- name: Install JDKs | |
run: |- | |
JVM_DIR=/usr/lib/jvm | |
TMP_JDK=/tmp/jdk.tar.gz | |
mkdir -p $JVM_DIR | |
cd $JVM_DIR | |
URL="${{ matrix.capella.jdk.url }}" | |
[[ -f $TMP_JDK ]] && rm $TMP_JDK | |
curl -Lo $TMP_JDK $URL | |
JDK_DIR_NAME=$(tar tf $TMP_JDK | head -n 1) | |
[[ -d $JDK_DIR_NAME ]] && rm -rf $JDK_DIR_NAME | |
tar xzf $TMP_JDK | |
mv $JVM_DIR/jdk-* /usr/lib/jvm/jdk | |
rm $TMP_JDK | |
# done | |
- name: Install Eclipse JDT language server | |
run: |- | |
if [ ! -d /tmp/jdtls ]; then mkdir /tmp/jdtls; fi | |
cd /tmp/jdtls | |
if [ ! -f jdtls.tar.gz ]; then | |
curl -Lo jdtls.tar.gz \ | |
https://download.eclipse.org/jdtls/milestones/1.40.0/jdt-language-server-1.40.0-202409261450.tar.gz | |
fi | |
tar xzf jdtls.tar.gz | |
rm *.tar.gz | |
# - name: Install `capella-addons` CLI tool | |
# run: |- | |
# pip install . | |
# pip show capella-addons | |
- name: Install dependencies for `capella-addons` CLI tool | |
run: |- | |
pip install click lxml | |
- name: Build `.classpath` file | |
run: |- | |
cd ${{ matrix.addon }} | |
python ../capella_addons/__main__.py build-classpath \ | |
--java-execution-environment=JavaSE-17 \ | |
$(find . -type f -name "Main.java") \ | |
/tmp/capella_${{ matrix.capella_version }} | |
cat .classpath | |
- name: Build workspace | |
run: |- | |
cd ${{ matrix.addon }} | |
rm -rf target | |
python ../capella_addons/__main__.py -v \ | |
build-workspace \ | |
--java-execution-environment=JavaSE-17 \ | |
/usr/lib/jvm/jdk-17.0.6+10 \ | |
/tmp/jdtls | |
- name: Package addon | |
run: |- | |
cd ${{ matrix.addon }} | |
python ../capella_addons/__main__.py -v \ | |
package \ | |
/usr/lib/jvm/${{ matrix.capella.jdk.name }} \ | |
/usr/lib/jvm/jdk-17.0.6+10 \ | |
/tmp/jdtls | |
- name: Release addon | |
run: |- | |
cd ${{ matrix.addon }} | |
- name: Create release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
- name: Publish release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ matrix.addon }}/target/*.jar | |
asset_name: com.deutschebahn.${{ matrix.addon }}_${{ github.ref }}.jar | |
asset_content_type: application/java-archive |