Skip to content

Commit

Permalink
docs: document the multi-stage upload feature
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasfara committed Jan 29, 2023
1 parent 5a034ae commit 67c992c
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,50 @@ flowchart LR
createStagingRepositoryOnRepositoryName --o uploadPublicationName2ToRepositoryNameNexus
```

## Multi-stage upload

This plugin, during the execution of the `createStagingRepositoryOn[Repo]` task, exports the staging repository ID in
the format `[Repo]StagingRepositoryId` as an output of the step.

Using this output, it is possible, from other jobs, to upload artifacts to the same staging repository by using the
`stagingRepositoryId` gradle property.

An example below shows how to use this feature to upload artifacts to a staging repository from a different job.

```yaml
jobs:
build:
runs-on: ubuntu-latest
outputs:
repositoryId: ${{ steps.createStagingRepository.outputs.MavenCentralStagingRepositoryId }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Gradle
run: ./gradlew build
- name: Create staging repository
id: createStagingRepository
# This step creates a staging repository on Maven Central and exports the staging repository ID as an output
run: ./gradlew createStagingRepositoryOnMavenCentral

release:
needs: build
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 11
- name: Use staging repository
# Use the staging repository ID exported by the previous job to upload artifacts to the same staging repository
run: ./gradlew -PstagingRepositoryId=${{ needs.build.outputs.repositoryId }} uploadAllPublicationsToMavenCentralNexus

```

## Usage examples

If you use publish-on-central in your project, please consider providing a pull request with a link to your project:
Expand Down

0 comments on commit 67c992c

Please sign in to comment.