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

feat: support wait for maven central #133

Merged
merged 8 commits into from
Sep 24, 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
17 changes: 11 additions & 6 deletions maven/await-artifact/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@
[![test-maven-await-artifact](https://github.com/elastic/oblt-actions/actions/workflows/test-elastic-active-branches.yml/badge.svg?branch=main)](https://github.com/elastic/oblt-actions/actions/workflows/test-maven-await-artifact.yml)

<!--description-->
Waits for an artifact to be available on maven central
Waits for an artifact to be available on maven central or the sonatype proxy maven central.
With default values, we just wait for the publication to complete on `sonatype`, but the actual availability in maven central might not be ready yet.
With `true`, we wait for the artifact to be published in maven central, this should be used when building other artifacts by downloading from maven central, which is for example quite common for docker images.
<!--/description-->

NOTE: this action does not timeout, hence you need to configure your GitHub workflow accordingly.
See https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepstimeout-minutes


## Inputs
<!--inputs-->
| Name | Description | Required | Default |
|---------------|-------------------------------------|----------|---------|
| `artifact-id` | Maven artifact-ID of the artifact | `true` | ` ` |
| `group-id` | Maven group-ID of the artifact | `true` | ` ` |
| `version` | Version of the artifact to wait for | `true` | ` ` |
| Name | Description | Required | Default |
|--------------------|--------------------------------------------------------------------------------------|----------|---------|
| `artifact-id` | Maven artifact-ID of the artifact | `true` | ` ` |
| `group-id` | Maven group-ID of the artifact | `true` | ` ` |
| `version` | Version of the artifact to wait for | `true` | ` ` |
| `sonatype-central` | Whether to wait for the artifact to be available in the sonatype central repository. | `false` | `true` |
| `maven-central` | Whether to wait for the artifact to be available in the maven central repository. | `false` | `false` |
<!--/inputs-->


Expand Down
37 changes: 33 additions & 4 deletions maven/await-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: maven/await-artifact
description: |
Waits for an artifact to be available on maven central
Waits for an artifact to be available on maven central or the sonatype proxy maven central.
v1v marked this conversation as resolved.
Show resolved Hide resolved
With default values, we just wait for the publication to complete on `sonatype`, but the actual availability in maven central might not be ready yet.
With `true`, we wait for the artifact to be published in maven central, this should be used when building other artifacts by downloading from maven central, which is for example quite common for docker images.
inputs:
artifact-id:
description: 'Maven artifact-ID of the artifact'
Expand All @@ -11,17 +13,44 @@ inputs:
version:
description: 'Version of the artifact to wait for'
required: true
sonatype-central:
description: 'Whether to wait for the artifact to be available in the sonatype central repository.'
default: true
required: false
maven-central:
description: 'Whether to wait for the artifact to be available in the maven central repository.'
default: false
required: false
runs:
using: "composite"
steps:
- name: Wait for artifact to be available on maven central
- name: Wait for artifact to be available on proxy sonatype maven central
if: ${{ inputs.sonatype-central == 'true' }}
shell: bash
run: |
TIME=30
full_url="https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=${GROUP_ID}&a=${ARTIFACT_ID}&v=${VERSION}"
until curl -fs -I -L "${full_url}" > /dev/null
do
echo "Artifact ${GROUP_ID}:${ARTIFACT_ID}:${VERSION} not found on maven central. Sleeping 30 seconds, retrying afterwards"
sleep 30s
echo "Artifact ${GROUP_ID}:${ARTIFACT_ID}:${VERSION} not found on proxy maven central. Sleeping ${WAIT_SECONDS} seconds, retrying afterwards"
sleep ${WAIT_SECONDS}s
done
env:
ARTIFACT_ID: ${{ inputs.artifact-id }}
GROUP_ID: ${{ inputs.group-id }}
VERSION: ${{ inputs.version }}

- name: Wait for artifact to be available on maven central
if: ${{ inputs.maven-central == 'true' }}
shell: bash
run: |
TIME=30
GROUP_FOLDER="${GROUP_ID//.//}"
full_url="https://repo.maven.apache.org/maven2/${GROUP_FOLDER}/${ARTIFACT_ID}/${VERSION}"
until curl -fs -I -L "${full_url}" > /dev/null
do
echo "Artifact ${GROUP_ID}:${ARTIFACT_ID}:${VERSION} not found on maven central. Sleeping ${WAIT_SECONDS} seconds, retrying afterwards"
sleep ${WAIT_SECONDS}s
done
env:
ARTIFACT_ID: ${{ inputs.artifact-id }}
Expand Down
Loading