Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant stage in publish #63

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/publish-snapshot-maven.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
################################################################################
# Copyright (c) 2021,2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
################################################################################
---
name: Publish SNAPSHOT version

on:
workflow_dispatch:
jobs:
publish-maven:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v2

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

# use the default GitHub runner user for the next steps
# this is needed during deploy, for pushing a tag
- name: Configure Git User
uses: fregante/setup-git-user@v2

# this is necessary because it creates gpg.conf, etc.
- name: List Keys
shell: bash
run: |
gpg -K --keyid-format=long

- name: Import GPG Private Key
shell: bash
run: |
echo "use-agent" >> ~/.gnupg/gpg.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
echo -e "${{ secrets.ORG_GPG_PRIVATE_KEY }}" | gpg --import --batch
for fpr in $(gpg --list-keys --with-colons | awk -F: '/fpr:/ {print $10}' | sort -u);
do
echo -e "5\\ny\\n" | gpg --batch --command-fd 0 --expert --edit-key $fpr trust;
done

# Environment variables used in settings.xml and pom.xml
- name: Publish to Maven
shell: bash
env:
MAVEN_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}
# command summary
# -B/--batch-mode: only display progress and errors
# -U: update snapshot-releases
# -Pci-cd: apply the ci-cd profile (in pom.xml)
# -s settings.xml: use custom settings file
run: |
if [[ $(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout) == *SNAPSHOT ]]; then
./mvnw -B -U \
-Pci-cd \
-s settings.xml \
deploy
fi

# artifact_name is cx-ssi-lib and the version should be the *-SNAPSHOT
# In the next step we'll use the releaseVersion to finalize the upload
- name: Get generated artifact name
shell: bash
run: |
echo "artifact_name=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> "$GITHUB_ENV"
echo "artifact_version=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)" >> "$GITHUB_ENV"

# Use the generated name to supply the input 'path' for the upload,
# but upload the final
# Example:
# input: cx-ssi-lib-0.0.1-SNAPSHOT.jar
# output: cx-ssi-lib-0.0.1.jar
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact_name }}-${{ inputs.releaseVersion }}
path: ./target/${{ env.artifact_name }}-${{ env.artifact_version }}.jar
60 changes: 23 additions & 37 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SPDX-License-Identifier: Apache-2.0
<modelVersion>4.0.0</modelVersion>
<groupId>org.eclipse.tractusx.ssi</groupId>
<artifactId>cx-ssi-lib</artifactId>
<version>0.0.18-SNAPSHOT</version>
<version>0.0.17-SNAPSHOT</version>
<packaging>jar</packaging>

<!-- required when publishing to Maven Central -->
Expand Down Expand Up @@ -234,19 +234,29 @@ SPDX-License-Identifier: Apache-2.0
</resource>
</resources>
<plugins>
<!--
The Maven Release Plugin can be used to automate the changes to the Maven POM files,
sanity checks, the SCM operations required and the actual deployment execution.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<tagNameFormat>@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>ci-cd</releaseProfiles>
<goals>deploy</goals>
</configuration>
<executions>
<execution>
<id>default</id>
<goals>
<goal>perform</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.dash</groupId>
Expand Down Expand Up @@ -371,30 +381,6 @@ SPDX-License-Identifier: Apache-2.0
<autoReleaseAfterClose>${env.AUTO_RELEASE_AFTER_CLOSE}</autoReleaseAfterClose>
</configuration>
</plugin>
<!--
The Maven Release Plugin can be used to automate the changes to the Maven POM files,
sanity checks, the SCM operations required and the actual deployment execution.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<tagNameFormat>@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>ci-cd</releaseProfiles>
<goals>deploy</goals>
</configuration>
<executions>
<execution>
<id>default</id>
<goals>
<goal>perform</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
Expand Down
Loading