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-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-move-artifacts/action.yml b/.github/actions/nexus-move-artifacts/action.yml new file mode 100644 index 000000000..ba84fcf43 --- /dev/null +++ b/.github/actions/nexus-move-artifacts/action.yml @@ -0,0 +1,71 @@ +name: Move artifacts to destination repository +description: Move artifacts to destination repository in Nexus 3 +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 + destination-repository: + description: The destination repository + required: true + 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 + 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 + env: + 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: | + 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/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 4ae727790..0bc164c41 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -386,23 +386,7 @@ updates: 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-release-staging" + directory: "/.github/actions/nexus-move-artifacts" schedule: interval: "weekly" groups: diff --git a/docs/README.md b/docs/README.md index f840e62a4..e70eea5e8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -69,9 +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-staging](#nexus-create-staging) - - [nexus-close-staging](#nexus-close-staging) - - [nexus-release-staging](#nexus-release-staging) + - [nexus-move-artifacts](#nexus-move-artifacts) - [pre-commit](#pre-commit) - [process-coverage-report](#process-coverage-report) - [pipenv](#pipenv) @@ -1028,44 +1026,20 @@ Updates pom files to the provided version version: 1.0.0-alpha.1 ``` -### nexus-create-staging +### nexus-move-artifacts -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`. +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-create-staging@ref + - uses: Alfresco/alfresco-build-tools/.github/actions/nexus-move-artifacts@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-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}} + 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 diff --git a/version.txt b/version.txt index ed15bef9a..d18077c21 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v6.1.0 +v7.0.0