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

refactor: extract a publish-maven-artifacts composite action #136

Merged
merged 1 commit into from
Aug 14, 2024
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
57 changes: 57 additions & 0 deletions .github/actions/publish-maven-artifacts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "Publish Maven Artifacts"
description: "Build and publish maven artifacts to repository"

inputs:
version:
description: the version to be attached to the artifacts, if not specified, the one configured in the project will be used
required: false
ref:
description: the git ref from which the artifacts will be built and published
required: true
gpg-private-key:
description: the gpg private key used to publish
required: true
gpg-passphrase:
description: the gpg passphrase used to publish
required: true
osshr-username:
description: the OSSHR username
required: true
osshr-password:
description: the OSSHR password
required: true

runs:
using: "composite"
steps:

- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}

- uses: eclipse-edc/.github/.github/actions/setup-build@main

- uses: eclipse-edc/.github/.github/actions/import-gpg-key@main
with:
gpg-private-key: ${{ inputs.gpg-private-key }}

- if: inputs.version != null
shell: bash
run: |
sed -i 's#^version=.*#version=${{ inputs.version }}#g' $(find . -name "gradle.properties")

- name: "Publish To OSSRH/MavenCentral"
shell: bash
env:
OSSRH_USER: ${{ inputs.osshr-username }}
OSSRH_PASSWORD: ${{ inputs.osshr-password }}
run: |-
VERSION=$(grep "version" gradle.properties | awk -F= '{print $2}')
cmd=""
if [[ $VERSION != *-SNAPSHOT ]]
then
cmd="closeAndReleaseSonatypeStagingRepository";
fi
echo "Publishing Version $VERSION to Sonatype"
./gradlew publishToSonatype ${cmd} --no-parallel -Pversion=$VERSION -Psigning.gnupg.executable=gpg -Psigning.gnupg.passphrase="${{ inputs.gpg-passphrase }}"

26 changes: 5 additions & 21 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,10 @@ jobs:
if: |
needs.secrets-presence.outputs.HAS_OSSRH
steps:
# Set-Up
- uses: actions/checkout@v4

# Import GPG Key
- uses: eclipse-edc/.github/.github/actions/import-gpg-key@main
name: "Import GPG Key"
- uses: eclipse-edc/.github/.github/actions/publish-maven-artifacts@main
with:
ref: main
gpg-private-key: ${{ secrets.ORG_GPG_PRIVATE_KEY }}

- uses: eclipse-edc/.github/.github/actions/setup-build@main
- name: "Publish snapshot version"
env:
OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
OSSRH_USER: ${{ secrets.ORG_OSSRH_USERNAME }}
run: |-
VERSION=$(./gradlew properties -q | grep "version: " | awk '{print $2}')
if [[ $VERSION != *-SNAPSHOT ]]
then
echo "::warning file=gradle.properties::$VERSION is not a snapshot version - will not publish!"
exit 0
fi
echo "Publishing Version $VERSION to Sonatype"
./gradlew publishToSonatype --no-parallel -Pversion=$VERSION -Psigning.gnupg.executable=gpg -Psigning.gnupg.passphrase="${{ secrets.ORG_GPG_PASSPHRASE }}"
gpg-passphrase: ${{ secrets.ORG_GPG_PASSPHRASE }}
osshr-username: ${{ secrets.ORG_OSSRH_USERNAME }}
osshr-password: ${{ secrets.ORG_OSSRH_PASSWORD }}
23 changes: 5 additions & 18 deletions .github/workflows/technology-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,14 @@ jobs:
needs: [ Determine-Version ]
if: needs.Secrets-Presence.outputs.HAS_OSSRH
steps:
- uses: actions/checkout@v4
- uses: eclipse-edc/.github/.github/actions/publish-maven-artifacts@main
with:
ref: ${{ inputs.branch }}

- uses: eclipse-edc/.github/.github/actions/setup-build@main

# Import GPG Key
- uses: eclipse-edc/.github/.github/actions/import-gpg-key@main
if: needs.Secrets-Presence.outputs.HAS_OSSRH
name: "Import GPG Key"
with:
version: ${{ needs.Determine-Version.outputs.VERSION }}
gpg-private-key: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
- name: "Publish To OSSRH/MavenCentral"
if: needs.Secrets-Presence.outputs.HAS_OSSRH
env:
OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
OSSRH_USER: ${{ secrets.ORG_OSSRH_USERNAME }}
VERSION: ${{ needs.Determine-Version.outputs.VERSION }}
run: |-
echo "Publishing Version $VERSION to Sonatype"
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --no-parallel -Pversion=$VERSION -Psigning.gnupg.executable=gpg -Psigning.gnupg.passphrase="${{ secrets.ORG_GPG_PASSPHRASE }}"
gpg-passphrase: ${{ secrets.ORG_GPG_PASSPHRASE }}
osshr-username: ${{ secrets.ORG_OSSRH_USERNAME }}
osshr-password: ${{ secrets.ORG_OSSRH_PASSWORD }}

Create-Tag:
needs: [ Publish-Artefacts ]
Expand Down
Loading