Skip to content

Commit

Permalink
WIP: Publish maven artifacts to GH Packages
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`.
Update `actions/setup-java@v3` to `actions/setup-java@v4`.
  • Loading branch information
sgraband committed Jun 3, 2024
1 parent 402d913 commit 02c29a1
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 1 deletion.
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/
70 changes: 70 additions & 0 deletions .github/workflows/reusable-maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Reusable workflow for maven packages

on:
workflow_call:
inputs:
path_to_package:
required: true
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: Verify package
run: |
cd ${{ inputs.path_to_package }}
mvn verify
check-version:
runs-on: ubuntu-latest
if: true || github.event_name == 'push' || github.event_name == 'release'
outputs:
is_snapshot_version: ${{ steps.version_check.outputs.is_snapshot_version }}
steps:
- 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: Publish package
run: |
cd ${{ inputs.path_to_package }}
mvn --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/test-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
Expand Down
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>
8 changes: 8 additions & 0 deletions java/common/org.eclipse.theia.cloud.common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@
</plugins>
</build>

<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 02c29a1

Please sign in to comment.