From 24ed63778bf5ac87a2b7185ae91644de30d2548f Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Tue, 27 Aug 2024 12:59:01 +0530 Subject: [PATCH 01/19] AAE-24324 add actions to create,associate tag and move artifacts --- .github/actions/maven-release/action.yml | 2 +- .../actions/nexus-associate-tag/action.yml | 42 +++++++++++++++++++ .github/actions/nexus-create-tag/action.yml | 39 +++++++++++++++++ .../actions/nexus-move-artifacts/action.yml | 38 +++++++++++++++++ .github/dependabot.yml | 24 +++++++++++ docs/README.md | 42 +++++++++++++++++++ 6 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 .github/actions/nexus-associate-tag/action.yml create mode 100644 .github/actions/nexus-create-tag/action.yml create mode 100644 .github/actions/nexus-move-artifacts/action.yml diff --git a/.github/actions/maven-release/action.yml b/.github/actions/maven-release/action.yml index 0e7066585..701326826 100644 --- a/.github/actions/maven-release/action.yml +++ b/.github/actions/maven-release/action.yml @@ -140,7 +140,7 @@ runs: -Dmaven.compiler.release="${JAVA_VERSION}" \ -Dmaven.artifact.threads=30 \ --batch-mode \ - -DaltReleaseDeploymentRepository=nexus-releases-staging-fixed::default::"${NEXUS_URL}"/service/local/staging/deployByRepositoryId/"$STAGING_REPOSITORY_ID " \ + -DaltReleaseDeploymentRepository=nexus-releases-staging-fixed::default::"${NEXUS_URL}"/content/repositories/"$STAGING_REPOSITORY_ID " \ -Dhttp.keepAlive=false \ -Dmaven.wagon.http.pool=false \ -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 diff --git a/.github/actions/nexus-associate-tag/action.yml b/.github/actions/nexus-associate-tag/action.yml new file mode 100644 index 000000000..a4e8d8411 --- /dev/null +++ b/.github/actions/nexus-associate-tag/action.yml @@ -0,0 +1,42 @@ +name: Associate tag with artifacts +description: Associate tag with artifacts in Nexus +inputs: + tag-name: + description: The name of the tag + required: true + nexus-username: + description: Nexus user name + required: true + nexus-password: + description: Nexus password + required: true + nexus-url: + description: Base URL to the Nexus server + required: false + default: "https://artifacts.alfresco.com/nexus" + group-id: + description: The maven group-id of the component + required: true + version: + description: The version of the component + required: true + +runs: + using: composite + steps: + - name: associate-tag + id: associate-tag + shell: bash + env: + TAG_NAME: ${{ inputs.tag-name }} + NEXUS_USERNAME: ${{ inputs.nexus-username }} + NEXUS_PASSWORD: ${{ inputs.nexus-password }} + NEXUS_URL: ${{ inputs.nexus-url }} + GROUP-ID: ${{ inputs.group }} + VERSION: ${{ inputs.version }} + run: | + echo "Associating tag $TAG_NAME with component $GROUP:$VERSION" + curl -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ + -X POST "${NEXUS_URL}/service/rest/v1/tags/associate/${TAG_NAME}&group=${GROUP-ID}&version=${VERSION}" \ + -H "Content-Type:application/json" \ + -d '{}' diff --git a/.github/actions/nexus-create-tag/action.yml b/.github/actions/nexus-create-tag/action.yml new file mode 100644 index 000000000..58a408afa --- /dev/null +++ b/.github/actions/nexus-create-tag/action.yml @@ -0,0 +1,39 @@ +name: Create nexus tag +description: Create a tag in Nexus +inputs: + tag-name: + description: The name of the tag to be created + required: true + nexus-username: + description: Nexus user name + required: true + nexus-password: + description: Nexus password + required: true + nexus-url: + description: Base URL to the Nexus server + required: false + default: "https://artifacts.alfresco.com/nexus" +outputs: + tag-name-created: + description: The name of the tag created + value: ${{ steps.create-nexus-tag.outputs.tag-name-created }} + +runs: + using: composite + steps: + - name: create-nexus-tag + id: create-nexus-tag + shell: bash + env: + TAG_NAME: ${{ inputs.tag-name }} + NEXUS_USERNAME: ${{ inputs.nexus-username }} + NEXUS_PASSWORD: ${{ inputs.nexus-password }} + NEXUS_URL: ${{ inputs.nexus-url }} + run: | + echo "Creating tag $TAG_NAME in Nexus" + curl -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ + -X POST --header 'Content-Type: application/json' \ + "${NEXUS_URL}/service/rest/v1/tags" \ + -d "{\"name\":\"$TAG_NAME\"}" + echo "tag-name-created=$TAG_NAME" >> $GITHUB_OUTPUT diff --git a/.github/actions/nexus-move-artifacts/action.yml b/.github/actions/nexus-move-artifacts/action.yml new file mode 100644 index 000000000..43c2e433b --- /dev/null +++ b/.github/actions/nexus-move-artifacts/action.yml @@ -0,0 +1,38 @@ +name: Move artifacts to staging repository +description: Move artifacts to staging repository in Nexus +inputs: + tag-name: + description: The name of the tag + required: true + nexus-username: + description: Nexus user name + required: true + nexus-password: + description: Nexus password + required: true + nexus-url: + description: Base URL to the Nexus server + required: false + default: "https://artifacts.alfresco.com/nexus" + staging-repository: + description: The destination staging repository + required: true + +runs: + using: composite + steps: + - name: move artifacts + id: move artifacts + shell: bash + env: + TAG_NAME: ${{ inputs.tag-name }} + NEXUS_USERNAME: ${{ inputs.nexus-username }} + NEXUS_PASSWORD: ${{ inputs.nexus-password }} + NEXUS_URL: ${{ inputs.nexus-url }} + STAGING_REPOSITORY: ${{ inputs.staging-repository }} + run: | + echo "Move artifacts with tag $TAG_NAME to staging repository $STAGING_REPOSITORY" + curl -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ + -X POST "${NEXUS_URL}/service/rest/v1/tags/move/{STAGING_REPOSITORY}?tag=${TAG_NAME}" \ + -H 'accept: application/json' \ + -d '{}' diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4ae727790..b62a57f59 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -385,6 +385,14 @@ updates: catch-all: patterns: - "*" + - package-ecosystem: "github-actions" + directory: "/.github/actions/nexus-associate-tag" + schedule: + interval: "weekly" + groups: + catch-all: + patterns: + - "*" - package-ecosystem: "github-actions" directory: "/.github/actions/nexus-close-staging" schedule: @@ -401,6 +409,22 @@ updates: catch-all: patterns: - "*" + - package-ecosystem: "github-actions" + directory: "/.github/actions/nexus-create-tag" + schedule: + interval: "weekly" + groups: + catch-all: + patterns: + - "*" + - package-ecosystem: "github-actions" + directory: "/.github/actions/nexus-move-artifacts" + schedule: + interval: "weekly" + groups: + catch-all: + patterns: + - "*" - package-ecosystem: "github-actions" directory: "/.github/actions/nexus-release-staging" schedule: diff --git a/docs/README.md b/docs/README.md index f840e62a4..2025e4d85 100644 --- a/docs/README.md +++ b/docs/README.md @@ -70,6 +70,9 @@ Here follows the list of GitHub Actions topics available in the current document - [maven-release](#maven-release) - [maven-update-pom-version](#maven-update-pom-version) - [nexus-create-staging](#nexus-create-staging) + - [nexus-create-tag](#nexus-create-tag) + - [nexus-associate-tag](#nexus-associate-tag) + - [nexus-move-artifacts](#nexus-move-artifacts) - [nexus-close-staging](#nexus-close-staging) - [nexus-release-staging](#nexus-release-staging) - [pre-commit](#pre-commit) @@ -1042,6 +1045,45 @@ The resulting staging repository will be available in the output named `staging- nexus-password: "${{ secrets.NEXUS_PASSWORD }}" ``` +### nexus-create-tag + +Creates a tag on Nexus with a specific name. The resulting tag will be available in the output named `tag-name`. + +```yaml + - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-create-tag@ref + with: + tag-name: ${{ needs.load-release-info.outputs.version }} + nexus-username: ${{ secrets.NEXUS_USERNAME }} + nexus-password: ${{ secrets.NEXUS_PASSWORD }} +``` + +### nexus-associate-tag + +Associates tag to artifacts on Nexus. The artifacts are filtered by provided maven group-id and version and then associated with the provided tag. + +```yaml + - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-associate-tags@ref + with: + tag-name: ${{needs.load-release-info.outputs.version }} + nexus-username: ${{ secrets.NEXUS_USERNAME }} + nexus-password: ${{ secrets.NEXUS_PASSWORD }} + group-id: maven-group-id + version: ${{ steps.load-descriptor.outputs.version }} +``` + +### nexus-move-artifacts + +Moves artifacts from one repository to another on Nexus. The action moves the artifacts associated with a particular tag to the staging repository. + +```yaml + - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-move-artifacts@ref + with: + tag-name: ${{ needs.load-release-info.outputs.version }} + staging-repository: staging-repository + nexus-username: ${{ secrets.NEXUS_USERNAME }} + nexus-password: ${{ secrets.NEXUS_PASSWORD }} +``` + ### nexus-close-staging Closes the specified staging repository on Nexus. From 1913f941e3157ac20253c61bd958a35ffb28f764 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Wed, 28 Aug 2024 11:52:21 +0530 Subject: [PATCH 02/19] AAE-24324 modify action to move artifacts --- .github/actions/nexus-move-artifacts/action.yml | 8 ++++---- docs/README.md | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/actions/nexus-move-artifacts/action.yml b/.github/actions/nexus-move-artifacts/action.yml index 43c2e433b..ad120e7d1 100644 --- a/.github/actions/nexus-move-artifacts/action.yml +++ b/.github/actions/nexus-move-artifacts/action.yml @@ -14,8 +14,8 @@ inputs: description: Base URL to the Nexus server required: false default: "https://artifacts.alfresco.com/nexus" - staging-repository: - description: The destination staging repository + destination-repository: + description: The destination repository required: true runs: @@ -29,10 +29,10 @@ runs: NEXUS_USERNAME: ${{ inputs.nexus-username }} NEXUS_PASSWORD: ${{ inputs.nexus-password }} NEXUS_URL: ${{ inputs.nexus-url }} - STAGING_REPOSITORY: ${{ inputs.staging-repository }} + DESTINATION_REPOSITORY: ${{ inputs.destination-repository }} run: | echo "Move artifacts with tag $TAG_NAME to staging repository $STAGING_REPOSITORY" curl -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ - -X POST "${NEXUS_URL}/service/rest/v1/tags/move/{STAGING_REPOSITORY}?tag=${TAG_NAME}" \ + -X POST "${NEXUS_URL}/service/rest/v1/tags/move/{DESTINATION_REPOSITORY}?tag=${TAG_NAME}" \ -H 'accept: application/json' \ -d '{}' diff --git a/docs/README.md b/docs/README.md index 2025e4d85..feefbb7a9 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1070,19 +1070,21 @@ Associates tag to artifacts on Nexus. The artifacts are filtered by provided mav group-id: maven-group-id version: ${{ steps.load-descriptor.outputs.version }} ``` +Assuming `maven-group-id` is the group id of the artifacts to be associated with the tag. ### nexus-move-artifacts -Moves artifacts from one repository to another on Nexus. The action moves the artifacts associated with a particular tag to the staging repository. +Moves artifacts from one repository to another on Nexus. The action moves the artifacts associated with a particular tag to the destination repository. ```yaml - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-move-artifacts@ref with: tag-name: ${{ needs.load-release-info.outputs.version }} - staging-repository: staging-repository + destination-repository: destination-repository nexus-username: ${{ secrets.NEXUS_USERNAME }} nexus-password: ${{ secrets.NEXUS_PASSWORD }} ``` +Assuming `destination-repository` is the repository where the artifacts will be moved. ### nexus-close-staging From 27b62ec6187cedf06bd202702a574b30514ea631 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Wed, 28 Aug 2024 11:54:54 +0530 Subject: [PATCH 03/19] AAE-24324 modify README.md --- docs/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/README.md b/docs/README.md index feefbb7a9..17d8437de 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1070,6 +1070,7 @@ Associates tag to artifacts on Nexus. The artifacts are filtered by provided mav group-id: maven-group-id version: ${{ steps.load-descriptor.outputs.version }} ``` + Assuming `maven-group-id` is the group id of the artifacts to be associated with the tag. ### nexus-move-artifacts @@ -1084,6 +1085,7 @@ Moves artifacts from one repository to another on Nexus. The action moves the ar nexus-username: ${{ secrets.NEXUS_USERNAME }} nexus-password: ${{ secrets.NEXUS_PASSWORD }} ``` + Assuming `destination-repository` is the repository where the artifacts will be moved. ### nexus-close-staging From 4119b1d4b04c5c0cbb130f44e36823ad8917a5b0 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Wed, 28 Aug 2024 12:02:41 +0530 Subject: [PATCH 04/19] AAE-24324 modify version --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index ed15bef9a..2dc8e03bc 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v6.1.0 +v6.2.0 From dab47bf2f234936cc1badb90b77380ee7dcd71c5 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Wed, 28 Aug 2024 12:20:13 +0530 Subject: [PATCH 05/19] AAE-24324 modify move artifacts action --- .github/actions/nexus-move-artifacts/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/nexus-move-artifacts/action.yml b/.github/actions/nexus-move-artifacts/action.yml index ad120e7d1..e1f1126c7 100644 --- a/.github/actions/nexus-move-artifacts/action.yml +++ b/.github/actions/nexus-move-artifacts/action.yml @@ -1,5 +1,5 @@ -name: Move artifacts to staging repository -description: Move artifacts to staging repository in Nexus +name: Move artifacts to destination repository +description: Move artifacts to destination repository in Nexus inputs: tag-name: description: The name of the tag From ad089139ed9c1beb350579ff18bb974d76328aa7 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Wed, 28 Aug 2024 17:44:32 +0530 Subject: [PATCH 06/19] AAE-24324 incorporate review comments --- .../actions/nexus-associate-tag/action.yml | 28 +++--- .../actions/nexus-close-staging/action.yml | 90 ------------------- .../close-payload-template.json | 8 -- .../actions/nexus-create-staging/action.yml | 58 ------------ .../staging-repository-payload-template.xml | 5 -- .github/actions/nexus-create-tag/action.yml | 21 ++--- .../actions/nexus-move-artifacts/action.yml | 20 +++-- .../actions/nexus-release-staging/action.yml | 78 ---------------- .../promote-payload-template.json | 9 -- .github/dependabot.yml | 24 ----- docs/README.md | 63 +++---------- version.txt | 2 +- 12 files changed, 45 insertions(+), 361 deletions(-) delete mode 100644 .github/actions/nexus-close-staging/action.yml delete mode 100644 .github/actions/nexus-close-staging/close-payload-template.json delete mode 100644 .github/actions/nexus-create-staging/action.yml delete mode 100644 .github/actions/nexus-create-staging/staging-repository-payload-template.xml delete mode 100644 .github/actions/nexus-release-staging/action.yml delete mode 100644 .github/actions/nexus-release-staging/promote-payload-template.json diff --git a/.github/actions/nexus-associate-tag/action.yml b/.github/actions/nexus-associate-tag/action.yml index a4e8d8411..935be2e16 100644 --- a/.github/actions/nexus-associate-tag/action.yml +++ b/.github/actions/nexus-associate-tag/action.yml @@ -1,24 +1,23 @@ name: Associate tag with artifacts description: Associate tag with artifacts in Nexus inputs: - tag-name: + tag: description: The name of the tag required: true nexus-username: - description: Nexus user name + description: Nexus username required: true nexus-password: description: Nexus password required: true nexus-url: description: Base URL to the Nexus server - required: false - default: "https://artifacts.alfresco.com/nexus" - group-id: - description: The maven group-id of the component + required: true + group: + description: The maven group-id of the components required: true version: - description: The version of the component + description: The version of the components required: true runs: @@ -28,15 +27,16 @@ runs: id: associate-tag shell: bash env: - TAG_NAME: ${{ inputs.tag-name }} + TAG: ${{ inputs.tag }} NEXUS_USERNAME: ${{ inputs.nexus-username }} NEXUS_PASSWORD: ${{ inputs.nexus-password }} NEXUS_URL: ${{ inputs.nexus-url }} - GROUP-ID: ${{ inputs.group }} + GROUP: ${{ inputs.group }} VERSION: ${{ inputs.version }} + run: | - echo "Associating tag $TAG_NAME with component $GROUP:$VERSION" - curl -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ - -X POST "${NEXUS_URL}/service/rest/v1/tags/associate/${TAG_NAME}&group=${GROUP-ID}&version=${VERSION}" \ - -H "Content-Type:application/json" \ - -d '{}' + echo "Associating tag $TAG with components from group $GROUP and version $VERSION" + curl -sSf -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ + -X POST "${NEXUS_URL}/service/rest/v1/tags/associate/${TAG}?group=${GROUP}&version=${VERSION}" \ + -H "Content-Type:application/json" \ + -d '{}' diff --git a/.github/actions/nexus-close-staging/action.yml b/.github/actions/nexus-close-staging/action.yml deleted file mode 100644 index ccfd15b43..000000000 --- a/.github/actions/nexus-close-staging/action.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: Close Nexus staging repository -description: Close a Nexus Staging Repository -inputs: - wait-for-completion: - description: Whether the action should wait for the closure to complete before returning - required: false - default: 'true' - max-await-attempts: - description: Max attempts while waiting for the repository to close - required: false - default: '12' - await-sleep-time: - description: Time in seconds between two attempts to verify if the staging repository has been closed - required: false - default: '5' - version: - description: Version being released. Used to update the repository description while closing the staging repository - required: true - staging-repository: - description: The id of the staging repository to be closed - required: true - nexus-username: - description: The Nexus username - required: true - nexus-password: - description: The Nexus password - required: true - nexus-url: - description: The base URL to the Nexus server - required: false - default: "https://artifacts.alfresco.com/nexus" -runs: - using: composite - steps: - - name: Close staging repository - shell: bash - env: - WAIT_FOR_COMPLETION: ${{ inputs.wait-for-completion }} - MAX_AWAIT_ATTEMPTS: ${{ inputs.max-await-attempts }} - AWAIT_SLEEP_TIME: ${{ inputs.await-sleep-time }} - NEXUS_USERNAME: ${{ inputs.nexus-username }} - NEXUS_PASSWORD: ${{ inputs.nexus-password }} - NEXUS_URL: ${{ inputs.nexus-url }} - VERSION: ${{ inputs.version }} - STAGING_REPOSITORY_ID: ${{ inputs.staging-repository }} - run: | - CLOSE_STAGING_PAYLOAD_CONTENT=$(envsubst < $GITHUB_ACTION_PATH/close-payload-template.json) - - staging_repo_is_closed () { - curl -f -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ - -X GET "${NEXUS_URL}"/service/local/staging/profile_repositories \ - | yq -p=xml e '.stagingRepositories.data.stagingProfileRepository[]| select (.repositoryId == env(STAGING_REPOSITORY_ID)) | .type ' \ - | grep closed > /dev/null 2>&1 - } - - if staging_repo_is_closed - then - echo "Repository $STAGING_REPOSITORY_ID is already closed. Skipping the close operation." - exit 0 - fi - - curl -f -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ - -H "Accept: application/json" \ - -H "Content-Type: application/json" \ - -d "$CLOSE_STAGING_PAYLOAD_CONTENT" \ - "${NEXUS_URL}"/service/local/staging/bulk/close - - wait_until_true () { - local attempt_counter=0 - until "$@" - do - if [ ${attempt_counter} -eq ${MAX_AWAIT_ATTEMPTS} ] - then - echo "Max attempts reached. Exiting..." - exit 1 - fi - - attempt_counter=$((attempt_counter+1)) - echo "Condition not reached yet. Attempt $attempt_counter out of $MAX_AWAIT_ATTEMPTS. Retrying..." - sleep $AWAIT_SLEEP_TIME - done - } - - if [[ "$WAIT_FOR_COMPLETION" == "true" ]] - then - echo "Waiting for staging repository $STAGING_REPOSITORY_ID to get closed. - MAX_AWAIT_ATTEMPTS: $MAX_AWAIT_ATTEMPTS, AWAIT_SLEEP_TIME: $AWAIT_SLEEP_TIME ..." - wait_until_true staging_repo_is_closed - echo "Repository $STAGING_REPOSITORY_ID successfully closed!" - fi diff --git a/.github/actions/nexus-close-staging/close-payload-template.json b/.github/actions/nexus-close-staging/close-payload-template.json deleted file mode 100644 index ed9117dd2..000000000 --- a/.github/actions/nexus-close-staging/close-payload-template.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "data": { - "description": "Closing $VERSION", - "stagedRepositoryIds": [ - "$STAGING_REPOSITORY_ID" - ] - } -} diff --git a/.github/actions/nexus-create-staging/action.yml b/.github/actions/nexus-create-staging/action.yml deleted file mode 100644 index 6fd7cafe4..000000000 --- a/.github/actions/nexus-create-staging/action.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Create staging repository -description: Create a new staging repository on Nexus, unless there is an existing repository with the same description -inputs: - staging-description: - description: The description of the staging repository - required: true - nexus-profile-id: - description: The id of the staging profile to be used to create the staging repository - required: true - nexus-username: - description: Nexus user name - required: true - nexus-password: - description: Nexus password - required: true - nexus-url: - description: Base URL to the Nexus server - required: false - default: "https://artifacts.alfresco.com/nexus" -outputs: - staging-repository: - description: The id of the staging repository - value: ${{steps.staging.outputs.staging-repository}} - -runs: - using: composite - steps: - - name: create-staging-repository - id: staging - shell: bash - env: - STAGING_DESCRIPTION: ${{ inputs.staging-description }} - NEXUS_PROFILE_ID: ${{ inputs.nexus-profile-id }} - NEXUS_USERNAME: ${{ inputs.nexus-username }} - NEXUS_PASSWORD: ${{ inputs.nexus-password }} - NEXUS_URL: ${{ inputs.nexus-url }} - run: | - echo "Checking repository to be used for $STAGING_DESCRIPTION" - NEXUS_STAGING_REPOSITORY=$(curl -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ - -X GET "${NEXUS_URL}"/service/local/staging/profile_repositories \ - | yq -p=xml e '.stagingRepositories.data.stagingProfileRepository[]| select (.description == env(STAGING_DESCRIPTION)) | .repositoryId') - - if [ -z "$NEXUS_STAGING_REPOSITORY" ]; - then - STAGING_DESCRIPTION_CONTENT=$(envsubst < $GITHUB_ACTION_PATH/staging-repository-payload-template.xml) - echo "Creating staging repository on Nexus with the following description: " - echo "$STAGING_DESCRIPTION_CONTENT" - NEXUS_STAGING_REPOSITORY=$(curl -d "$STAGING_DESCRIPTION_CONTENT" \ - -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ - -H "Content-Type:application/xml" \ - "${NEXUS_URL}"/service/local/staging/profiles/"${NEXUS_PROFILE_ID}"/start | \ - yq -p=xml e '.promoteResponse.data.stagedRepositoryId') - echo "Staging repository $NEXUS_STAGING_REPOSITORY created." - else - echo "Reusing existing staging repository $NEXUS_STAGING_REPOSITORY" - fi - - echo "staging-repository=$NEXUS_STAGING_REPOSITORY" >> $GITHUB_OUTPUT diff --git a/.github/actions/nexus-create-staging/staging-repository-payload-template.xml b/.github/actions/nexus-create-staging/staging-repository-payload-template.xml deleted file mode 100644 index e16a82b22..000000000 --- a/.github/actions/nexus-create-staging/staging-repository-payload-template.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - $STAGING_DESCRIPTION - - diff --git a/.github/actions/nexus-create-tag/action.yml b/.github/actions/nexus-create-tag/action.yml index 58a408afa..c3da45f7d 100644 --- a/.github/actions/nexus-create-tag/action.yml +++ b/.github/actions/nexus-create-tag/action.yml @@ -1,23 +1,18 @@ name: Create nexus tag description: Create a tag in Nexus inputs: - tag-name: + tag: description: The name of the tag to be created required: true nexus-username: - description: Nexus user name + description: Nexus username required: true nexus-password: description: Nexus password required: true nexus-url: description: Base URL to the Nexus server - required: false - default: "https://artifacts.alfresco.com/nexus" -outputs: - tag-name-created: - description: The name of the tag created - value: ${{ steps.create-nexus-tag.outputs.tag-name-created }} + required: true runs: using: composite @@ -26,14 +21,14 @@ runs: id: create-nexus-tag shell: bash env: - TAG_NAME: ${{ inputs.tag-name }} + TAG: ${{ inputs.tag }} NEXUS_USERNAME: ${{ inputs.nexus-username }} NEXUS_PASSWORD: ${{ inputs.nexus-password }} NEXUS_URL: ${{ inputs.nexus-url }} + run: | - echo "Creating tag $TAG_NAME in Nexus" - curl -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ + echo "Creating tag $TAG in Nexus" + curl -sSf -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ -X POST --header 'Content-Type: application/json' \ "${NEXUS_URL}/service/rest/v1/tags" \ - -d "{\"name\":\"$TAG_NAME\"}" - echo "tag-name-created=$TAG_NAME" >> $GITHUB_OUTPUT + -d "{\"name\":\"$TAG\"}" diff --git a/.github/actions/nexus-move-artifacts/action.yml b/.github/actions/nexus-move-artifacts/action.yml index e1f1126c7..bd2eaa68a 100644 --- a/.github/actions/nexus-move-artifacts/action.yml +++ b/.github/actions/nexus-move-artifacts/action.yml @@ -1,22 +1,24 @@ name: Move artifacts to destination repository description: Move artifacts to destination repository in Nexus inputs: - tag-name: + tag: description: The name of the tag required: true nexus-username: - description: Nexus user name + description: Nexus username required: true nexus-password: description: Nexus password required: true nexus-url: description: Base URL to the Nexus server - required: false - default: "https://artifacts.alfresco.com/nexus" + required: true destination-repository: description: The destination repository required: true + source-repository: + description: The source repository + required: true runs: using: composite @@ -25,14 +27,16 @@ runs: id: move artifacts shell: bash env: - TAG_NAME: ${{ inputs.tag-name }} + TAG: ${{ inputs.tag }} NEXUS_USERNAME: ${{ inputs.nexus-username }} NEXUS_PASSWORD: ${{ inputs.nexus-password }} NEXUS_URL: ${{ inputs.nexus-url }} DESTINATION_REPOSITORY: ${{ inputs.destination-repository }} + SOURCE_REPOSITORY: ${{ inputs.source-repository }} + run: | - echo "Move artifacts with tag $TAG_NAME to staging repository $STAGING_REPOSITORY" - curl -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ - -X POST "${NEXUS_URL}/service/rest/v1/tags/move/{DESTINATION_REPOSITORY}?tag=${TAG_NAME}" \ + echo "Moving artifacts with tag $TAG to destination repository ${DESTINATION_REPOSITORY} from source repository ${SOURCE_REPOSITORY} in Nexus" + curl -sSf -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ + -X POST "${NEXUS_URL}/service/rest/v1/staging/move/${DESTINATION_REPOSITORY}?tag=${TAG}&repository=${SOURCE_REPOSITORY}" \ -H 'accept: application/json' \ -d '{}' diff --git a/.github/actions/nexus-release-staging/action.yml b/.github/actions/nexus-release-staging/action.yml deleted file mode 100644 index f4128d296..000000000 --- a/.github/actions/nexus-release-staging/action.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Release Nexus staging repository -description: Release a Nexus Staging Repository. The stage repository should be in the closed status. -inputs: - wait-for-completion: - description: Whether the action should wait for the release to complete before returning - required: false - default: 'true' - max-await-attempts: - description: Max attempts while waiting for the repository to release - required: false - default: '12' - await-sleep-time: - description: Time in seconds between two attempts to verify if the staging repository has been released - required: false - default: '5' - version: - description: Version being released. Used to update the repository description while closing and releasing - required: true - staging-repository: - description: The id of the staging repository to be promoted - required: true - nexus-username: - description: The Nexus username - required: true - nexus-password: - description: The Nexus password - required: true - nexus-url: - description: The base URL to the Nexus server - required: false - default: "https://artifacts.alfresco.com/nexus" -runs: - using: composite - steps: - - name: Release staging repository - shell: bash - env: - WAIT_FOR_COMPLETION: ${{ inputs.wait-for-completion }} - MAX_AWAIT_ATTEMPTS: ${{ inputs.max-await-attempts }} - AWAIT_SLEEP_TIME: ${{ inputs.await-sleep-time }} - NEXUS_USERNAME: ${{ inputs.nexus-username }} - NEXUS_PASSWORD: ${{ inputs.nexus-password }} - NEXUS_URL: ${{ inputs.nexus-url }} - VERSION: ${{ inputs.version }} - STAGING_REPOSITORY_ID: ${{ inputs.staging-repository }} - run: | - PROMOTE_PAYLOAD_CONTENT=$(envsubst < $GITHUB_ACTION_PATH/promote-payload-template.json) - curl -f -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ - -H "Accept: application/json" \ - -H "Content-Type: application/json" \ - -d "$PROMOTE_PAYLOAD_CONTENT" \ - "${NEXUS_URL}"/service/local/staging/bulk/promote - - wait_until_released () { - local attempt_counter=0 - until [ -z "$(curl -f -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ - -X GET "${NEXUS_URL}"/service/local/staging/profile_repositories \ - | yq -p=xml e '.stagingRepositories.data.stagingProfileRepository[]| select (.repositoryId == env(STAGING_REPOSITORY_ID))')" ] - do - if [ ${attempt_counter} -eq ${MAX_AWAIT_ATTEMPTS} ] - then - echo "Max attempts reached. Exiting..." - exit 1 - fi - - attempt_counter=$((attempt_counter+1)) - echo "Condition not reached yet. Attempt $attempt_counter out of $MAX_AWAIT_ATTEMPTS. Retrying..." - sleep $AWAIT_SLEEP_TIME - done - } - - if [[ "$WAIT_FOR_COMPLETION" == "true" ]] - then - echo "Waiting for staging repository $STAGING_REPOSITORY_ID to get released. - MAX_AWAIT_ATTEMPTS: $MAX_AWAIT_ATTEMPTS, AWAIT_SLEEP_TIME: $AWAIT_SLEEP_TIME ..." - wait_until_released - echo "Repository $STAGING_REPOSITORY_ID successfully released!" - fi diff --git a/.github/actions/nexus-release-staging/promote-payload-template.json b/.github/actions/nexus-release-staging/promote-payload-template.json deleted file mode 100644 index f79f0b4ac..000000000 --- a/.github/actions/nexus-release-staging/promote-payload-template.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "data": { - "autoDropAfterRelease": true, - "description": "Releasing $VERSION", - "stagedRepositoryIds": [ - "$STAGING_REPOSITORY_ID" - ] - } -} diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b62a57f59..cbfa46534 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -393,22 +393,6 @@ updates: catch-all: patterns: - "*" - - package-ecosystem: "github-actions" - directory: "/.github/actions/nexus-close-staging" - schedule: - interval: "weekly" - groups: - catch-all: - patterns: - - "*" - - package-ecosystem: "github-actions" - directory: "/.github/actions/nexus-create-staging" - schedule: - interval: "weekly" - groups: - catch-all: - patterns: - - "*" - package-ecosystem: "github-actions" directory: "/.github/actions/nexus-create-tag" schedule: @@ -425,14 +409,6 @@ updates: catch-all: patterns: - "*" - - package-ecosystem: "github-actions" - directory: "/.github/actions/nexus-release-staging" - schedule: - interval: "weekly" - groups: - catch-all: - patterns: - - "*" - package-ecosystem: "github-actions" directory: "/.github/actions/pipenv" schedule: diff --git a/docs/README.md b/docs/README.md index 17d8437de..122549ce2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -69,12 +69,9 @@ Here follows the list of GitHub Actions topics available in the current document - [maven-deploy-file](#maven-deploy-file) - [maven-release](#maven-release) - [maven-update-pom-version](#maven-update-pom-version) - - [nexus-create-staging](#nexus-create-staging) - [nexus-create-tag](#nexus-create-tag) - [nexus-associate-tag](#nexus-associate-tag) - [nexus-move-artifacts](#nexus-move-artifacts) - - [nexus-close-staging](#nexus-close-staging) - - [nexus-release-staging](#nexus-release-staging) - [pre-commit](#pre-commit) - [process-coverage-report](#process-coverage-report) - [pipenv](#pipenv) @@ -1031,30 +1028,17 @@ Updates pom files to the provided version version: 1.0.0-alpha.1 ``` -### nexus-create-staging - -Creates a new staging repository on Nexus, unless there is an existing repository with the same description. -The resulting staging repository will be available in the output named `staging-repository`. - -```yaml - - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-create-staging@ref - with: - staging-description: Activiti staging ${{ steps.load-descriptor.outputs.version }} - nexus-profile-id: "${{ secrets.NEXUS_ACTIVITI7_PROFILE_ID }}" - nexus-username: "${{ secrets.NEXUS_USERNAME }}" - nexus-password: "${{ secrets.NEXUS_PASSWORD }}" -``` - ### nexus-create-tag -Creates a tag on Nexus with a specific name. The resulting tag will be available in the output named `tag-name`. +Creates a tag on Nexus with a specific name. ```yaml - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-create-tag@ref with: - tag-name: ${{ needs.load-release-info.outputs.version }} + tag: 1.0.0 nexus-username: ${{ secrets.NEXUS_USERNAME }} nexus-password: ${{ secrets.NEXUS_PASSWORD }} + nexus-url: ${{ vars.NEXUS_URL }} ``` ### nexus-associate-tag @@ -1064,15 +1048,14 @@ Associates tag to artifacts on Nexus. The artifacts are filtered by provided mav ```yaml - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-associate-tags@ref with: - tag-name: ${{needs.load-release-info.outputs.version }} + tag: 1.0.0 nexus-username: ${{ secrets.NEXUS_USERNAME }} nexus-password: ${{ secrets.NEXUS_PASSWORD }} - group-id: maven-group-id - version: ${{ steps.load-descriptor.outputs.version }} + nexus-url: ${{ vars.NEXUS_URL }} + group: com.company + version: 1.0.0 ``` -Assuming `maven-group-id` is the group id of the artifacts to be associated with the tag. - ### nexus-move-artifacts Moves artifacts from one repository to another on Nexus. The action moves the artifacts associated with a particular tag to the destination repository. @@ -1080,38 +1063,12 @@ Moves artifacts from one repository to another on Nexus. The action moves the ar ```yaml - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-move-artifacts@ref with: - tag-name: ${{ needs.load-release-info.outputs.version }} + tag: 1.0.0 destination-repository: destination-repository + source-repository: source-repository nexus-username: ${{ secrets.NEXUS_USERNAME }} nexus-password: ${{ secrets.NEXUS_PASSWORD }} -``` - -Assuming `destination-repository` is the repository where the artifacts will be moved. - -### nexus-close-staging - -Closes the specified staging repository on Nexus. - -```yaml - - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-close-staging@ref - with: - version: ${{ inputs.version }} - staging-repository: ${{ inputs.staging-repository}} - nexus-username: ${{ secrets.NEXUS_USERNAME }} - nexus-password: ${{ secrets.NEXUS_PASSWORD }} -``` - -### nexus-release-staging - -Releases the specified staging repository on Nexus. The repository should be in the closed status before. - -```yaml - - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-release-staging@ref - with: - version: ${{ inputs.version }} - staging-repository: ${{ inputs.staging-repository}} - nexus-username: ${{ secrets.NEXUS_USERNAME }} - nexus-password: ${{ secrets.NEXUS_PASSWORD }} + nexus-url: ${{ vars.NEXUS_URL }} ``` ### pre-commit diff --git a/version.txt b/version.txt index 2dc8e03bc..d18077c21 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v6.2.0 +v7.0.0 From 2929e5efacc38cc26c61bcc0d609767aca88d0d4 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Wed, 28 Aug 2024 17:47:13 +0530 Subject: [PATCH 07/19] AAE-24324 fix pre-commit --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 122549ce2..b2f529c27 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1030,7 +1030,7 @@ Updates pom files to the provided version ### nexus-create-tag -Creates a tag on Nexus with a specific name. +Creates a tag on Nexus with a specific name. ```yaml - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-create-tag@ref From cde82088a8a3ee54f333a7f0cb88270127bba777 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Thu, 29 Aug 2024 11:45:09 +0530 Subject: [PATCH 08/19] AAE-24324 modify move artifacts action --- .github/actions/nexus-move-artifacts/action.yml | 16 ++++++++++------ docs/README.md | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/actions/nexus-move-artifacts/action.yml b/.github/actions/nexus-move-artifacts/action.yml index bd2eaa68a..43659178f 100644 --- a/.github/actions/nexus-move-artifacts/action.yml +++ b/.github/actions/nexus-move-artifacts/action.yml @@ -1,9 +1,6 @@ name: Move artifacts to destination repository description: Move artifacts to destination repository in Nexus inputs: - tag: - description: The name of the tag - required: true nexus-username: description: Nexus username required: true @@ -19,6 +16,12 @@ inputs: source-repository: description: The source repository required: true + group: + description: The maven group-id of the components to be moved + required: true + version: + description: The version of the components to be moved + required: true runs: using: composite @@ -27,16 +30,17 @@ runs: id: move artifacts shell: bash env: - TAG: ${{ inputs.tag }} NEXUS_USERNAME: ${{ inputs.nexus-username }} NEXUS_PASSWORD: ${{ inputs.nexus-password }} NEXUS_URL: ${{ inputs.nexus-url }} DESTINATION_REPOSITORY: ${{ inputs.destination-repository }} SOURCE_REPOSITORY: ${{ inputs.source-repository }} + GROUP: ${{ inputs.group }} + VERSION: ${{ inputs.version }} run: | - echo "Moving artifacts with tag $TAG to destination repository ${DESTINATION_REPOSITORY} from source repository ${SOURCE_REPOSITORY} in Nexus" + echo "Moving artifacts to destination repository ${DESTINATION_REPOSITORY} from source repository ${SOURCE_REPOSITORY} in Nexus" curl -sSf -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ - -X POST "${NEXUS_URL}/service/rest/v1/staging/move/${DESTINATION_REPOSITORY}?tag=${TAG}&repository=${SOURCE_REPOSITORY}" \ + -X POST "${NEXUS_URL}/service/rest/v1/staging/move/$destination_repository?repository=${SOURCE_REPOSITORY}&group=${GROUP}&version=${VERSION}" \ -H 'accept: application/json' \ -d '{}' diff --git a/docs/README.md b/docs/README.md index b2f529c27..4b3862757 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1063,12 +1063,13 @@ Moves artifacts from one repository to another on Nexus. The action moves the ar ```yaml - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-move-artifacts@ref with: - tag: 1.0.0 destination-repository: destination-repository source-repository: source-repository nexus-username: ${{ secrets.NEXUS_USERNAME }} nexus-password: ${{ secrets.NEXUS_PASSWORD }} nexus-url: ${{ vars.NEXUS_URL }} + group: com.company + version: 1.0.0 ``` ### pre-commit From faa37918e5e92b8f3603d9e31d9ff76966aab2b3 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Thu, 29 Aug 2024 12:16:41 +0530 Subject: [PATCH 09/19] AAE-24324 modify move artifacts action --- .github/actions/nexus-move-artifacts/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/nexus-move-artifacts/action.yml b/.github/actions/nexus-move-artifacts/action.yml index 43659178f..1f2bedce8 100644 --- a/.github/actions/nexus-move-artifacts/action.yml +++ b/.github/actions/nexus-move-artifacts/action.yml @@ -41,6 +41,6 @@ runs: run: | echo "Moving artifacts to destination repository ${DESTINATION_REPOSITORY} from source repository ${SOURCE_REPOSITORY} in Nexus" curl -sSf -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ - -X POST "${NEXUS_URL}/service/rest/v1/staging/move/$destination_repository?repository=${SOURCE_REPOSITORY}&group=${GROUP}&version=${VERSION}" \ + -X POST "${NEXUS_URL}/service/rest/v1/staging/move/${DESTINATION_REPOSITORY}?repository=${SOURCE_REPOSITORY}&group=${GROUP}&version=${VERSION}" \ -H 'accept: application/json' \ -d '{}' From c3b048542d490d7b31b017d0d46c9f93961f4a23 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Thu, 29 Aug 2024 13:42:40 +0530 Subject: [PATCH 10/19] AAE-24324 modify README.md --- docs/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/README.md b/docs/README.md index 4b3862757..2b2d540e8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1030,7 +1030,7 @@ Updates pom files to the provided version ### nexus-create-tag -Creates a tag on Nexus with a specific name. +Creates a tag on Nexus 3 with the given name. ```yaml - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-create-tag@ref @@ -1043,7 +1043,7 @@ Creates a tag on Nexus with a specific name. ### nexus-associate-tag -Associates tag to artifacts on Nexus. The artifacts are filtered by provided maven group-id and version and then associated with the provided tag. +Associates a tag with artifacts on Nexus 3. The artifacts are filtered by the provided Maven group-id and version, and then associated with the given tag. ```yaml - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-associate-tags@ref @@ -1058,7 +1058,7 @@ Associates tag to artifacts on Nexus. The artifacts are filtered by provided mav ### nexus-move-artifacts -Moves artifacts from one repository to another on Nexus. The action moves the artifacts associated with a particular tag to the destination repository. +Moves artifacts from one repository to another on Nexus 3, identified by a particular group and version. ```yaml - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-move-artifacts@ref From ae9ad86fe29a0f08ef76f26414740e2aa522f4cf Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Thu, 29 Aug 2024 16:32:56 +0530 Subject: [PATCH 11/19] AAE-24324 modify action move-artifacts --- .github/actions/nexus-move-artifacts/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/actions/nexus-move-artifacts/action.yml b/.github/actions/nexus-move-artifacts/action.yml index 1f2bedce8..e4d6a4d33 100644 --- a/.github/actions/nexus-move-artifacts/action.yml +++ b/.github/actions/nexus-move-artifacts/action.yml @@ -26,8 +26,8 @@ inputs: runs: using: composite steps: - - name: move artifacts - id: move artifacts + - name: move-artifacts + id: move-artifacts shell: bash env: NEXUS_USERNAME: ${{ inputs.nexus-username }} From 982c078da1d130dea84738df106299f2ada79b1f Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Thu, 29 Aug 2024 18:11:20 +0530 Subject: [PATCH 12/19] AAE-24324 modify action move-artifacts --- .github/actions/nexus-move-artifacts/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/nexus-move-artifacts/action.yml b/.github/actions/nexus-move-artifacts/action.yml index e4d6a4d33..b7f1daf45 100644 --- a/.github/actions/nexus-move-artifacts/action.yml +++ b/.github/actions/nexus-move-artifacts/action.yml @@ -42,5 +42,6 @@ runs: echo "Moving artifacts to destination repository ${DESTINATION_REPOSITORY} from source repository ${SOURCE_REPOSITORY} in Nexus" curl -sSf -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ -X POST "${NEXUS_URL}/service/rest/v1/staging/move/${DESTINATION_REPOSITORY}?repository=${SOURCE_REPOSITORY}&group=${GROUP}&version=${VERSION}" \ + -H 'Content-Type: application/json' \ -H 'accept: application/json' \ -d '{}' From 63a6e0031deaef4a14eeac735b13c31cf7574539 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Fri, 30 Aug 2024 12:27:57 +0530 Subject: [PATCH 13/19] AAE-24324 add action to count artifacts --- .../actions/nexus-count-artifacts/action.yml | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/actions/nexus-count-artifacts/action.yml diff --git a/.github/actions/nexus-count-artifacts/action.yml b/.github/actions/nexus-count-artifacts/action.yml new file mode 100644 index 000000000..142377dd8 --- /dev/null +++ b/.github/actions/nexus-count-artifacts/action.yml @@ -0,0 +1,53 @@ +name: Count artifacts in Nexus Repository +description: Count artifacts in Nexus Repository +inputs: + nexus-username: + description: Nexus username + required: true + nexus-password: + description: Nexus password + required: true + nexus-url: + description: Base URL to the Nexus server + required: true + repository: + description: The repository to count artifacts + required: true + group: + description: The maven group-id of the components to be moved + required: true + version: + description: The version of the components to be moved + required: true +outputs: + artifact_count: + description: The number of artifacts in the repository + +runs: + using: composite + steps: + - name: search artifacts in Nexus + id: search-artifacts + shell: bash + env: + NEXUS_USERNAME: ${{ inputs.nexus-username }} + NEXUS_PASSWORD: ${{ inputs.nexus-password }} + NEXUS_URL: ${{ inputs.nexus-url }} + REPOSITORY: ${{ inputs.repository }} + GROUP: ${{ inputs.group }} + VERSION: ${{ inputs.version }} + + run: | + echo "Counting artifacts in repository ${REPOSITORY} in Nexus" + search_response=$(curl -sSf -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ + -X GET "${NEXUS_URL}/service/rest/v1/search?repository=${REPOSITORY}&group=${GROUP}&version=${VERSION}" \ + -H 'Content-Type: application/json' \ + -H 'accept: application/json' \ + -d '{}') + artifact_count=$(echo "$search_response" | yq '.items | length') + echo "Artifact Count: $artifact_count" + echo "artifact_count=$artifact_count" >> $GITHUB_ENV + + - name: set output + id: set-output + run: echo "::set-output name=artifact_count::${{ steps.search-artifacts.outputs.artifact_count }}" From d1ff02ebfd59eb520ec500701873760252c3f67b Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Fri, 30 Aug 2024 12:39:16 +0530 Subject: [PATCH 14/19] AAE-24324 modify action to count artifacts --- .github/actions/nexus-count-artifacts/action.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/actions/nexus-count-artifacts/action.yml b/.github/actions/nexus-count-artifacts/action.yml index 142377dd8..b29e611f1 100644 --- a/.github/actions/nexus-count-artifacts/action.yml +++ b/.github/actions/nexus-count-artifacts/action.yml @@ -22,12 +22,13 @@ inputs: outputs: artifact_count: description: The number of artifacts in the repository + value: ${{ steps.count-artifacts.outputs.artifact_count }} runs: using: composite steps: - - name: search artifacts in Nexus - id: search-artifacts + - name: count artifacts in Nexus + id: count-artifacts shell: bash env: NEXUS_USERNAME: ${{ inputs.nexus-username }} @@ -46,8 +47,4 @@ runs: -d '{}') artifact_count=$(echo "$search_response" | yq '.items | length') echo "Artifact Count: $artifact_count" - echo "artifact_count=$artifact_count" >> $GITHUB_ENV - - - name: set output - id: set-output - run: echo "::set-output name=artifact_count::${{ steps.search-artifacts.outputs.artifact_count }}" + echo "artifact_count=$artifact_count" >> $GITHUB_OUTPUT From c9e99a82d13896b07611c29a6bfe2cc8696a6147 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Fri, 30 Aug 2024 12:42:10 +0530 Subject: [PATCH 15/19] AAE-24324 modify action to count artifacts --- .github/dependabot.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index cbfa46534..3f8fead35 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -401,6 +401,14 @@ updates: catch-all: patterns: - "*" + - package-ecosystem: "github-actions" + directory: "/.github/actions/nexus-count-artifacts" + schedule: + interval: "weekly" + groups: + catch-all: + patterns: + - "*" - package-ecosystem: "github-actions" directory: "/.github/actions/nexus-move-artifacts" schedule: From 92be05c9e37b178bb2e478e4075c4dc6ee2e99f0 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Fri, 30 Aug 2024 12:43:33 +0530 Subject: [PATCH 16/19] AAE-24324 modify dependabot.yml --- .github/dependabot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3f8fead35..f76db7464 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -394,7 +394,7 @@ updates: patterns: - "*" - package-ecosystem: "github-actions" - directory: "/.github/actions/nexus-create-tag" + directory: "/.github/actions/nexus-count-artifacts" schedule: interval: "weekly" groups: @@ -402,7 +402,7 @@ updates: patterns: - "*" - package-ecosystem: "github-actions" - directory: "/.github/actions/nexus-count-artifacts" + directory: "/.github/actions/nexus-create-tag" schedule: interval: "weekly" groups: From 18d14b351f201ecc9220f7506df487761cfa39d2 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Fri, 30 Aug 2024 15:03:56 +0530 Subject: [PATCH 17/19] AAE-24324 modify README.md --- .../actions/nexus-associate-tag/action.yml | 42 ------------------- .github/actions/nexus-create-tag/action.yml | 34 --------------- .github/dependabot.yml | 16 ------- docs/README.md | 29 ++++--------- 4 files changed, 9 insertions(+), 112 deletions(-) delete mode 100644 .github/actions/nexus-associate-tag/action.yml delete mode 100644 .github/actions/nexus-create-tag/action.yml diff --git a/.github/actions/nexus-associate-tag/action.yml b/.github/actions/nexus-associate-tag/action.yml deleted file mode 100644 index 935be2e16..000000000 --- a/.github/actions/nexus-associate-tag/action.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Associate tag with artifacts -description: Associate tag with artifacts in Nexus -inputs: - tag: - description: The name of the tag - required: true - nexus-username: - description: Nexus username - required: true - nexus-password: - description: Nexus password - required: true - nexus-url: - description: Base URL to the Nexus server - required: true - group: - description: The maven group-id of the components - required: true - version: - description: The version of the components - required: true - -runs: - using: composite - steps: - - name: associate-tag - id: associate-tag - shell: bash - env: - TAG: ${{ inputs.tag }} - NEXUS_USERNAME: ${{ inputs.nexus-username }} - NEXUS_PASSWORD: ${{ inputs.nexus-password }} - NEXUS_URL: ${{ inputs.nexus-url }} - GROUP: ${{ inputs.group }} - VERSION: ${{ inputs.version }} - - run: | - echo "Associating tag $TAG with components from group $GROUP and version $VERSION" - curl -sSf -u "${NEXUS_USERNAME}":"${NEXUS_PASSWORD}" \ - -X POST "${NEXUS_URL}/service/rest/v1/tags/associate/${TAG}?group=${GROUP}&version=${VERSION}" \ - -H "Content-Type:application/json" \ - -d '{}' diff --git a/.github/actions/nexus-create-tag/action.yml b/.github/actions/nexus-create-tag/action.yml deleted file mode 100644 index c3da45f7d..000000000 --- a/.github/actions/nexus-create-tag/action.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Create nexus tag -description: Create a tag in Nexus -inputs: - tag: - description: The name of the tag to be created - required: true - nexus-username: - description: Nexus username - required: true - nexus-password: - description: Nexus password - required: true - nexus-url: - description: Base URL to the Nexus server - required: true - -runs: - using: composite - steps: - - name: create-nexus-tag - id: create-nexus-tag - shell: bash - env: - TAG: ${{ inputs.tag }} - NEXUS_USERNAME: ${{ inputs.nexus-username }} - NEXUS_PASSWORD: ${{ inputs.nexus-password }} - NEXUS_URL: ${{ inputs.nexus-url }} - - run: | - echo "Creating tag $TAG in Nexus" - curl -sSf -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ - -X POST --header 'Content-Type: application/json' \ - "${NEXUS_URL}/service/rest/v1/tags" \ - -d "{\"name\":\"$TAG\"}" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f76db7464..e5137f98a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -385,14 +385,6 @@ updates: catch-all: patterns: - "*" - - package-ecosystem: "github-actions" - directory: "/.github/actions/nexus-associate-tag" - schedule: - interval: "weekly" - groups: - catch-all: - patterns: - - "*" - package-ecosystem: "github-actions" directory: "/.github/actions/nexus-count-artifacts" schedule: @@ -401,14 +393,6 @@ updates: catch-all: patterns: - "*" - - package-ecosystem: "github-actions" - directory: "/.github/actions/nexus-create-tag" - schedule: - interval: "weekly" - groups: - catch-all: - patterns: - - "*" - package-ecosystem: "github-actions" directory: "/.github/actions/nexus-move-artifacts" schedule: diff --git a/docs/README.md b/docs/README.md index 2b2d540e8..1d299a8b6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -69,8 +69,7 @@ Here follows the list of GitHub Actions topics available in the current document - [maven-deploy-file](#maven-deploy-file) - [maven-release](#maven-release) - [maven-update-pom-version](#maven-update-pom-version) - - [nexus-create-tag](#nexus-create-tag) - - [nexus-associate-tag](#nexus-associate-tag) + - [nexus-count-artifacts](#nexus-count-artifacts) - [nexus-move-artifacts](#nexus-move-artifacts) - [pre-commit](#pre-commit) - [process-coverage-report](#process-coverage-report) @@ -1027,28 +1026,18 @@ Updates pom files to the provided version with: version: 1.0.0-alpha.1 ``` +### nexus-count-artifacts -### nexus-create-tag - -Creates a tag on Nexus 3 with the given name. - -```yaml - - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-create-tag@ref - with: - tag: 1.0.0 - nexus-username: ${{ secrets.NEXUS_USERNAME }} - nexus-password: ${{ secrets.NEXUS_PASSWORD }} - nexus-url: ${{ vars.NEXUS_URL }} -``` - -### nexus-associate-tag - -Associates a tag with artifacts on Nexus 3. The artifacts are filtered by the provided Maven group-id and version, and then associated with the given tag. +Count artifacts in a Nexus 3 repository, identified by a particular group and version. ```yaml - - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-associate-tags@ref + outputs: + artifact_count: ${{ steps.count-artifacts.outputs.artifact_count }} + steps: + - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-count-artifacts@ref + id: count-artifacts with: - tag: 1.0.0 + repository: repository nexus-username: ${{ secrets.NEXUS_USERNAME }} nexus-password: ${{ secrets.NEXUS_PASSWORD }} nexus-url: ${{ vars.NEXUS_URL }} From 2997a17827b572636b51502422c52899c6b353f9 Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Fri, 30 Aug 2024 15:05:22 +0530 Subject: [PATCH 18/19] AAE-24324 fix pre-commit --- docs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/README.md b/docs/README.md index 1d299a8b6..4c7ac9510 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1026,6 +1026,7 @@ Updates pom files to the provided version with: version: 1.0.0-alpha.1 ``` + ### nexus-count-artifacts Count artifacts in a Nexus 3 repository, identified by a particular group and version. From 6549ab24cffc303d3d9deb1ad82f94a2aaa5f1fb Mon Sep 17 00:00:00 2001 From: revatilimaye Date: Mon, 2 Sep 2024 11:49:50 +0530 Subject: [PATCH 19/19] AAE-24324 embed count-artifacts in move-artifacts --- .../actions/nexus-count-artifacts/action.yml | 50 ------------------- .../actions/nexus-move-artifacts/action.yml | 40 ++++++++++++--- .github/dependabot.yml | 8 --- docs/README.md | 20 -------- 4 files changed, 32 insertions(+), 86 deletions(-) delete mode 100644 .github/actions/nexus-count-artifacts/action.yml diff --git a/.github/actions/nexus-count-artifacts/action.yml b/.github/actions/nexus-count-artifacts/action.yml deleted file mode 100644 index b29e611f1..000000000 --- a/.github/actions/nexus-count-artifacts/action.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Count artifacts in Nexus Repository -description: Count artifacts in Nexus Repository -inputs: - nexus-username: - description: Nexus username - required: true - nexus-password: - description: Nexus password - required: true - nexus-url: - description: Base URL to the Nexus server - required: true - repository: - description: The repository to count artifacts - required: true - group: - description: The maven group-id of the components to be moved - required: true - version: - description: The version of the components to be moved - required: true -outputs: - artifact_count: - description: The number of artifacts in the repository - value: ${{ steps.count-artifacts.outputs.artifact_count }} - -runs: - using: composite - steps: - - name: count artifacts in Nexus - id: count-artifacts - shell: bash - env: - NEXUS_USERNAME: ${{ inputs.nexus-username }} - NEXUS_PASSWORD: ${{ inputs.nexus-password }} - NEXUS_URL: ${{ inputs.nexus-url }} - REPOSITORY: ${{ inputs.repository }} - GROUP: ${{ inputs.group }} - VERSION: ${{ inputs.version }} - - run: | - echo "Counting artifacts in repository ${REPOSITORY} in Nexus" - search_response=$(curl -sSf -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ - -X GET "${NEXUS_URL}/service/rest/v1/search?repository=${REPOSITORY}&group=${GROUP}&version=${VERSION}" \ - -H 'Content-Type: application/json' \ - -H 'accept: application/json' \ - -d '{}') - artifact_count=$(echo "$search_response" | yq '.items | length') - echo "Artifact Count: $artifact_count" - echo "artifact_count=$artifact_count" >> $GITHUB_OUTPUT diff --git a/.github/actions/nexus-move-artifacts/action.yml b/.github/actions/nexus-move-artifacts/action.yml index b7f1daf45..ba84fcf43 100644 --- a/.github/actions/nexus-move-artifacts/action.yml +++ b/.github/actions/nexus-move-artifacts/action.yml @@ -1,5 +1,5 @@ name: Move artifacts to destination repository -description: Move artifacts to destination repository in Nexus +description: Move artifacts to destination repository in Nexus 3 inputs: nexus-username: description: Nexus username @@ -26,6 +26,26 @@ inputs: runs: using: composite steps: + - name: count-artifacts + id: count-artifacts + shell: bash + env: + NEXUS_USERNAME: ${{ inputs.nexus-username }} + NEXUS_PASSWORD: ${{ inputs.nexus-password }} + NEXUS_URL: ${{ inputs.nexus-url }} + SOURCE_REPOSITORY: ${{ inputs.source-repository }} + GROUP: ${{ inputs.group }} + VERSION: ${{ inputs.version }} + run: | + echo "Counting artifacts in repository ${SOURCE_REPOSITORY} in Nexus" + search_response=$(curl -sSf -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ + -X GET "${NEXUS_URL}/service/rest/v1/search?repository=${SOURCE_REPOSITORY}&group=${GROUP}&version=${VERSION}" \ + -H 'Content-Type: application/json' \ + -H 'accept: application/json' \ + -d '{}') + count=$(echo "$search_response" | yq '.items | length') + echo "count=$count" >> $GITHUB_OUTPUT + - name: move-artifacts id: move-artifacts shell: bash @@ -37,11 +57,15 @@ runs: SOURCE_REPOSITORY: ${{ inputs.source-repository }} GROUP: ${{ inputs.group }} VERSION: ${{ inputs.version }} - run: | - echo "Moving artifacts to destination repository ${DESTINATION_REPOSITORY} from source repository ${SOURCE_REPOSITORY} in Nexus" - curl -sSf -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ - -X POST "${NEXUS_URL}/service/rest/v1/staging/move/${DESTINATION_REPOSITORY}?repository=${SOURCE_REPOSITORY}&group=${GROUP}&version=${VERSION}" \ - -H 'Content-Type: application/json' \ - -H 'accept: application/json' \ - -d '{}' + count="${{ steps.count-artifacts.outputs.count }}" + if [ $count -eq 0 ]; then + echo "No artifacts found in repository ${SOURCE_REPOSITORY} for group ${GROUP} and version ${VERSION}" + else + echo "Moving artifacts to destination repository ${DESTINATION_REPOSITORY} from source repository ${SOURCE_REPOSITORY} in Nexus" + curl -sSf -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" \ + -X POST "${NEXUS_URL}/service/rest/v1/staging/move/${DESTINATION_REPOSITORY}?repository=${SOURCE_REPOSITORY}&group=${GROUP}&version=${VERSION}" \ + -H 'Content-Type: application/json' \ + -H 'accept: application/json' \ + -d '{}' + fi diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e5137f98a..0bc164c41 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -385,14 +385,6 @@ updates: catch-all: patterns: - "*" - - package-ecosystem: "github-actions" - directory: "/.github/actions/nexus-count-artifacts" - schedule: - interval: "weekly" - groups: - catch-all: - patterns: - - "*" - package-ecosystem: "github-actions" directory: "/.github/actions/nexus-move-artifacts" schedule: diff --git a/docs/README.md b/docs/README.md index 4c7ac9510..e70eea5e8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -69,7 +69,6 @@ Here follows the list of GitHub Actions topics available in the current document - [maven-deploy-file](#maven-deploy-file) - [maven-release](#maven-release) - [maven-update-pom-version](#maven-update-pom-version) - - [nexus-count-artifacts](#nexus-count-artifacts) - [nexus-move-artifacts](#nexus-move-artifacts) - [pre-commit](#pre-commit) - [process-coverage-report](#process-coverage-report) @@ -1027,25 +1026,6 @@ Updates pom files to the provided version version: 1.0.0-alpha.1 ``` -### nexus-count-artifacts - -Count artifacts in a Nexus 3 repository, identified by a particular group and version. - -```yaml - outputs: - artifact_count: ${{ steps.count-artifacts.outputs.artifact_count }} - steps: - - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-count-artifacts@ref - id: count-artifacts - with: - repository: repository - nexus-username: ${{ secrets.NEXUS_USERNAME }} - nexus-password: ${{ secrets.NEXUS_PASSWORD }} - nexus-url: ${{ vars.NEXUS_URL }} - group: com.company - version: 1.0.0 -``` - ### nexus-move-artifacts Moves artifacts from one repository to another on Nexus 3, identified by a particular group and version.