Skip to content

Commit

Permalink
Dat 15505 (#69)
Browse files Browse the repository at this point in the history
* feat(pom-release-published.yml): add workflow for releasing extension to Sonatype Maven Central Repository

This commit adds a new workflow file `pom-release-published.yml` that is triggered when a workflow call event occurs. The workflow is triggered by the caller workflow and requires the `SONATYPE_USERNAME` and `SONATYPE_TOKEN` secrets to be provided.

The `release` job in the workflow runs on the `ubuntu-latest` environment and performs the following steps:
1. Checks out the repository using `actions/checkout@v3`.
2. Sets up Java for publishing to the Maven Central Repository using `actions/setup-java@v3`. The Java version is set to `17` and the distribution is set to `temurin`. The Maven cache is also configured.
3. Configures Git with the username and email.
4. Builds the release artifacts using Maven. The `release:clean` and `release:prepare` goals are executed with the necessary arguments. The release version is obtained from the `liquibaseVersion` input provided by the caller workflow. The changes are not pushed to the remote repository.
5. Retrieves the artifact ID from the Maven project and sets it as an environment variable.
6. Downloads the release artifacts using `robinraju/release-downloader@v1.6`. The artifacts are downloaded based on the tag name and the artifact ID.
7. Publishes the artifacts to the Maven Central Repository using the `maven-deploy-plugin`. The Maven username and password are obtained from the `SONATYPE_USERNAME` and `SONATYPE_TOKEN` secrets respectively. The POM file and its associated files are deployed to the Sonatype Nexus staging repository.

The `maven-release` job is dependent on the `release` job and uses the `liquibase/build-logic/.github/workflows/extension-release-prepare.yml@v0.4.2` action. The secrets are inherited from the `release` job.

No newline at end of file.

* chore(README.md): add new workflow `pom-release-published.yml` to the table

The `pom-release-published.yml` workflow is responsible for publishing a release pom to Maven Central. This workflow is added to the table of reusable workflows in the README.md file to provide visibility and documentation for this new workflow.

* chore(pom-release-published.yml): remove unnecessary line break and trailing whitespace for better readability
chore(pom-release-published.yml): remove unused parameters in maven-release step to simplify the command

* fix(pom-release-published.yml): add missing file and classifiers options to maven deploy command

The maven deploy command was missing the file and classifiers options, which caused the pom.asc file to not be deployed. This commit adds the missing options to ensure that the pom.asc file is included in the deployment.

* fix(pom-release-published.yml): remove unnecessary options from maven deploy command

The options `-Dfiles`, `-Dtypes`, and `-Dclassifiers` were removed from the maven deploy command as they were not needed.

* fix(pom-release-published.yml): add additional parameters to the Maven deploy command to include the .asc file for GPG signature
feat(pom-release-published.yml): add a new job 'maven-release' that depends on the 'release' job

* fix(pom-release-published.yml): remove unnecessary options from maven deploy command

The options `-Dfiles=${{ env.artifact_id }}-${version}.pom.asc`, `-Dtypes=asc`, and `-Dclassifiers=asc` were removed from the maven deploy command as they are unnecessary and do not affect the deployment process.

* fix(pom-release-published.yml): add the generated POM.asc file to the Maven release command to include it in the release artifacts

* chore(pom-release-published.yml): add classifiers option to maven-release step to include pom.asc file in the release artifacts

* fix(pom-release-published.yml): remove the 'classifiers' argument from the Maven command to fix an issue with releasing the POM file

* fix(pom-release-published.yml): fix the file name in the -Dfiles parameter to include the file extension
fix(pom-release-published.yml): add the pom.asc classifier to the -Dclassifiers parameter to include the asc file in the deployment

* fix(pom-release-published.yml): fix the file name in the -Dfiles parameter to include the .pom extension
fix(pom-release-published.yml): fix the -Dclassifiers parameter value to be 'asc' instead of 'pom.asc'

* fix(pom-release-published.yml): remove unnecessary classifier value in maven-release step

The classifier value in the maven-release step was set to a comma (,) which is unnecessary. This commit removes the classifier value to improve the clarity and correctness of the workflow.

* fix(pom-release-published.yml): fix missing backslash at the end of line 58 to properly escape the line continuation
fix(pom-release-published.yml): fix missing comma in line 62 to separate classifiers

* fix(pom-release-published.yml): add a missing backslash to the end of the line to properly continue the command on the next line

* fix(pom-release-published.yml): remove unnecessary configuration for generating pom.asc file during release

The configuration for generating the pom.asc file was removed as it is not needed for the release process.

* fix(pom-release-published.yml): change maven-deploy-plugin command from deploy-file to deploy to match the correct plugin goal

* chore(pom-release-published.yml): update workflow name to accurately reflect its purpose
feat(pom-release-published.yml): add support for deploying additional files (sources, javadoc, and signatures) to Sonatype repository for better artifact management
  • Loading branch information
jandroav authored Sep 15, 2023
1 parent 01601fc commit 0b4e70e
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/pom-release-published.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Release POM to Sonatype

on:
workflow_call:
secrets:
SONATYPE_USERNAME:
description: 'SONATYPE_USERNAME from the caller workflow'
required: true
SONATYPE_TOKEN:
description: 'SONATYPE_TOKEN from the caller workflow'
required: true

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
server-id: sonatype-nexus-staging
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD

- name: Configure Git
run: |
git config user.name "liquibot"
git config user.email "liquibot@liquibase.org"
- name: Build release artifacts
id: build-release-artifacts
run: |
mvn -B release:clean release:prepare -Dusername=liquibot -Dpassword=$GITHUB_TOKEN -Darguments="-Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true -Dmaven.deploy.skip=true" -DreleaseVersion=${{ github.event.inputs.liquibaseVersion }} -DpushChanges=false
git reset HEAD~ --hard
- name: Get Artifact ID
id: get-artifact-id
run: echo "artifact_id=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_ENV

- name: Download Release Artifacts
uses: robinraju/release-downloader@v1.6
with:
tag: "${{ github.event.release.tag_name }}"
filename: "${{ env.artifact_id }}-*"
out-file-path: "."

- name: Publish to Maven Central
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.SONATYPE_TOKEN }}
run: |
version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=sonatype-nexus-staging \
-DpomFile=${{ env.artifact_id }}-${version}.pom \
-DgeneratePom=false \
-Dfile=${{ env.artifact_id }}-${version}.pom \
-Dsources=${{ env.artifact_id }}-${version}-sources.jar \
-Djavadoc=${{ env.artifact_id }}-${version}-javadoc.jar \
-Dfiles=${{ env.artifact_id }}-${version}-sources.jar.asc,${{ env.artifact_id }}-${version}-javadoc.jar.asc,${{ env.artifact_id }}-${version}.pom.asc \
-Dtypes=jar.asc,jar.asc,pom.asc \
-Dclassifiers=sources,javadoc,
maven-release:
needs: release
uses: liquibase/build-logic/.github/workflows/extension-release-prepare.yml@v0.4.2
secrets: inherit
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Please review the below table of reusable workflows and their descriptions:
| `extension-update-version.yml` | Updates release and development `pom.xml` versions |
| `os-extension-test.yml` | Unit tests across build matrix on previously built artifact |
| `package-deb.yml` | Creates and uploads deb packages |
| `pom-release-published.yml` | Publishes a release pom to Maven Central |
| `pro-extension-test.yml` | Same as OS job, but with additional Pro-only vars such as License Key |
| `sonar-pull-request.yml` | Code Coverage Scan for PRs. Requires branch name parameter |
| `sonar-test-scan.yml` | Code Coverage Scan for unit and integration tests |
Expand Down

0 comments on commit 0b4e70e

Please sign in to comment.