Skip to content

Commit

Permalink
Add publishing to Google Artifact Registry
Browse files Browse the repository at this point in the history
Pass secrets from parent workflows.
Add profile for publishing to Google.
Adjust workflow to publish to both Google and Github.
  • Loading branch information
sgraband committed Jul 9, 2024
1 parent a94b633 commit 2271868
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-maven-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ jobs:
uses: ./.github/workflows/reusable-maven.yml
with:
path_to_package: common/org.eclipse.theia.cloud.common/
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/ci-maven-conf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ jobs:
uses: ./.github/workflows/reusable-maven.yml
with:
path_to_package: common/maven-conf/
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/ci-maven-operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ jobs:
with:
path_to_package: operator/org.eclipse.theia.cloud.operator/
dependencies: common/maven-conf/,common/org.eclipse.theia.cloud.common/
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/ci-maven-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ jobs:
with:
path_to_package: service/org.eclipse.theia.cloud.service/
dependencies: common/maven-conf/,common/org.eclipse.theia.cloud.common/
secrets: inherit
26 changes: 22 additions & 4 deletions .github/workflows/reusable-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

# Only continue from here when the version matches the event, so either:
# - main merge with snapshot version
# - release with proper version
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
Expand Down Expand Up @@ -63,9 +66,6 @@ jobs:
echo "is_snapshot_version=false" >> $GITHUB_OUTPUT
fi
# Only continue from here when the version matches the event, so either:
# - main merge with snapshot version
# - release with proper version
- name: Set up JDK 17
if: |
(github.event_name == 'push' && steps.version_check.outputs.is_snapshot_version == 'true') ||
Expand All @@ -89,7 +89,7 @@ jobs:
cd -
done
- name: Publish package
- name: Publish package to GitHub Packages
if: |
(github.event_name == 'push' && steps.version_check.outputs.is_snapshot_version == 'true') ||
(github.event_name == 'release' && steps.version_check.outputs.is_snapshot_version == 'false')
Expand All @@ -98,3 +98,21 @@ jobs:
mvn --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Authenticate to Google Cloud
if: |
(github.event_name == 'push' && steps.version_check.outputs.is_snapshot_version == 'true') ||
(github.event_name == 'release' && steps.version_check.outputs.is_snapshot_version == 'false')
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'

- name: Publish package to Google Artifact Registry
if: |
(github.event_name == 'push' && steps.version_check.outputs.is_snapshot_version == 'true') ||
(github.event_name == 'release' && steps.version_check.outputs.is_snapshot_version == 'false')
run: |
cd ${{ inputs.path_to_package }}
mvn --batch-mode deploy -Partifact-registry
env:
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
54 changes: 47 additions & 7 deletions java/common/maven-conf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,52 @@
<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>
<profiles>
<profile>
<id>github</id>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/eclipsesource/theia-cloud</url>
</repository>
</distributionManagement>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>

<profile>
<id>artifact-registry</id>
<distributionManagement>
<snapshotRepository>
<id>artifact-registry</id>
<name>Google Artifact Registry</name>
<url>artifactregistry://europe-west3-maven.pkg.dev/kubernetes-238012/theia-cloud</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>artifact-registry</id>
<url>artifactregistry://europe-west3-maven.pkg.dev/kubernetes-238012/theia-cloud</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.artifactregistry</groupId>
<artifactId>artifactregistry-maven-wagon</artifactId>
<version>2.2.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit 2271868

Please sign in to comment.