Skip to content

Commit

Permalink
Publish maven artifacts to GH Packages (#305)
Browse files Browse the repository at this point in the history
Provide reusable maven ci workflow.
Publish `maven-conf` and `org.eclipse.theia.cloud.common`.
Publish `org.eclipse.theia.cloud.operator` and `org.eclipse.theia.cloud.service`.
Always resolve `maven-conf` and `org.eclipse.theia.cloud.common` locally.
Update `actions/setup-java@v3` to `actions/setup-java@v4`.
Remove the service tests, as they are indirectly run via the maven build.
  • Loading branch information
sgraband authored Jun 5, 2024
1 parent 402d913 commit 2d1d439
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 32 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/ci-maven-common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Maven org.eclipse.theia.cloud.common CI

on:
push:
branches:
- main
paths:
- "java/common/**"
pull_request:
branches:
- main
paths:
- "java/common/**"
release:
types:
- published

jobs:
call-reusable-maven-workflow:
permissions:
packages: write
uses: ./.github/workflows/reusable-maven.yml
with:
path_to_package: common/org.eclipse.theia.cloud.common/
24 changes: 24 additions & 0 deletions .github/workflows/ci-maven-conf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Maven config CI

on:
push:
branches:
- main
paths:
- "java/common/maven-conf/**"
pull_request:
branches:
- main
paths:
- "java/common/maven-conf/**"
release:
types:
- published

jobs:
call-reusable-maven-workflow:
permissions:
packages: write
uses: ./.github/workflows/reusable-maven.yml
with:
path_to_package: common/maven-conf/
27 changes: 27 additions & 0 deletions .github/workflows/ci-maven-operator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Maven org.eclipse.theia.cloud.operator CI

on:
push:
branches:
- main
paths:
- "java/common/**"
- "java/operator/org.eclipse.theia.cloud.operator/**"
pull_request:
branches:
- main
paths:
- "java/common/**"
- "java/operator/org.eclipse.theia.cloud.operator/**"
release:
types:
- published

jobs:
call-reusable-maven-workflow:
permissions:
packages: write
uses: ./.github/workflows/reusable-maven.yml
with:
path_to_package: operator/org.eclipse.theia.cloud.operator/
dependencies: common/maven-conf/,common/org.eclipse.theia.cloud.common/
26 changes: 26 additions & 0 deletions .github/workflows/ci-maven-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Maven org.eclipse.theia.cloud.service CI
on:
push:
branches:
- main
paths:
- "java/common/**"
- "java/service/org.eclipse.theia.cloud.service/**"
pull_request:
branches:
- main
paths:
- "java/common/**"
- "java/service/org.eclipse.theia.cloud.service/**"
release:
types:
- published

jobs:
call-reusable-maven-workflow:
permissions:
packages: write
uses: ./.github/workflows/reusable-maven.yml
with:
path_to_package: service/org.eclipse.theia.cloud.service/
dependencies: common/maven-conf/,common/org.eclipse.theia.cloud.common/
98 changes: 98 additions & 0 deletions .github/workflows/reusable-maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Reusable workflow for maven packages

on:
workflow_call:
inputs:
path_to_package:
required: true
type: string
dependencies:
description: "List of paths to dependencies. Entries are relative to the java directory and separated by comma (no whitespaces)."
required: false
type: string

defaults:
run:
working-directory: java

jobs:
build:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"

- name: Build dependencies
if: ${{ inputs.dependencies != '' }}
run: |
IFS=',' read -r -a dirs <<< "${{ inputs.dependencies }}"
for dir in "${dirs[@]}"
do
cd "$dir"
mvn clean install --no-transfer-progress
cd -
done
- name: Verify package
run: |
cd ${{ inputs.path_to_package }}
mvn verify -fae --no-transfer-progress
check-version:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event_name == 'release'
outputs:
is_snapshot_version: ${{ steps.version_check.outputs.is_snapshot_version }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- id: version_check
run: |
cd ${{ inputs.path_to_package }}
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
if [[ "$VERSION" == *-SNAPSHOT ]]; then
echo "is_snapshot_version=true" >> $GITHUB_OUTPUT
else
echo "is_snapshot_version=false" >> $GITHUB_OUTPUT
fi
publish:
runs-on: ubuntu-latest
needs: check-version
if: (github.event_name == 'push' && needs.check-version.outputs.is_snapshot_version == 'true') || (github.event_name == 'release' && needs.check-version.outputs.is_snapshot_version == 'false')

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"

- name: Build dependencies
if: ${{ inputs.dependencies != '' }}
run: |
IFS=',' read -r -a dirs <<< "${{ inputs.dependencies }}"
for dir in "${dirs[@]}"
do
cd "$dir"
mvn clean install --no-transfer-progress
cd -
done
- name: Publish package
run: |
cd ${{ inputs.path_to_package }}
mvn --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 0 additions & 32 deletions .github/workflows/test-service.yml

This file was deleted.

8 changes: 8 additions & 0 deletions java/common/maven-conf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@
<webhooks.framework.core.version>1.1.2</webhooks.framework.core.version>
</properties>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/eclipsesource/theia-cloud</url>
</repository>
</distributionManagement>

</project>

0 comments on commit 2d1d439

Please sign in to comment.