-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from borisrizov-zf/ci/add-maven-publish-workflow
ci: add maven publish workflow
- Loading branch information
Showing
5 changed files
with
260 additions
and
30 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
################################################################################ | ||
# 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 | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
releaseVersion: | ||
description: The version you want to release | ||
required: true | ||
type: string | ||
developmentVersion: | ||
description: The development version to assign after the release | ||
required: true | ||
type: string | ||
auto_release: | ||
description: A switch for automatic release after closing the staging repository | ||
required: false | ||
type: boolean | ||
default: false | ||
# only committers can trigger this | ||
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 | ||
|
||
- name: Import GPG Key | ||
uses: crazy-max/ghaction-import-gpg@v5.0.0 | ||
with: | ||
gpg_private_key: ${{ secrets.ORG_GPG_PRIVATE_KEY }} | ||
passphrase: ${{ secrets.ORG_GPG_PASSPHRASE }} | ||
|
||
# Environment variables used in settings.xml and pom.xml | ||
- name: Publish to Maven | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }} | ||
AUTO_RELEASE_AFTER_CLOSE: ${{ inputs.auto_release }} | ||
# command summary | ||
# -B/--batch-mode: only display progress and errors | ||
# -U: update snapshot-releases | ||
# -Pci-cd: apply the ci-cd profile (in pom.xml) | ||
# release:prepare (comes from maven-release-plugin) | ||
# release:perform (comes from maven-release-plugin) | ||
# javadoc:jar: checks documentation strings | ||
# source:jar: creates a <lib>-<version>-source.jar | ||
# -s settings.xml: use custom settings file | ||
# -D gpg.passphrase: a system property used by the build process for signing | ||
# -D releaseVersion: set the version you're releasing (will also tag using this) | ||
# -D developmentVersion: set the next dev version | ||
run: |- | ||
echo "Publishing using version: ${{ inputs.version }}" | ||
./mvnw -B -U \ | ||
-Pci-cd \ | ||
release:prepare \ | ||
release:perform \ | ||
javadoc:jar \ | ||
source:jar \ | ||
-s settings.xml \ | ||
-D gpg.passphrase=${{ secrets.ORG_GPG_PASSPHRASE }} \ | ||
-D releaseVersion=${{ inputs.releaseVersion }} \ | ||
-D developmentVersion=${{ inputs.developmentVersion }} \ | ||
deploy | ||
# 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 | ||
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 |
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
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
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
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