Skip to content
Snippets Groups Projects
Commit 8815b796 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Create a script to deploy the artifacts to Maven Central

Fixes #1640
parent 2cd00b6c
No related branches found
No related tags found
1 merge request!948Deploy the artifacts to Maven Central
Pipeline #88147 passed with stage
in 17 minutes and 59 seconds
# Deploy artifacts
## Prerequisites
### Signing
Use [this guide](https://github.com/drduh/YubiKey-Guide#configure-smartcard) to setup a yubikey with the VideoLAN maven signing key. The key id is `e8f8f982a0cd726f020ced90f4b3cd9a1faeefe8`
### Utilities
Apache Maven is needed.
`sudo apt install maven`
### Sonatype
You have to get Sonatype credentials. To ask for it, you will have to create a JIRA account and ask to be added [here](https://issues.sonatype.org/browse/OSSRH-65611)
## Generate the artifacts
Create a git tag named `libvlc-[libvlc-version]`. The CI will generate the libvlc and medialibrary artifacts and the debug symbols. All of these files will be available to download in a zip file named `dbg.zip` attached to the pipeline.
Copy the file to this directory (`buildsystem/maven`)
## Usage
You just have to plug your yubikey and run the script
`./deploy-to-mavencentral.sh`
The script will do the following actions:
- check if the zip exists
- unzip it
- look for the artifact versions
- let you confirm if it's all good
- let you enter your Sonatype credentials
- create a new `settings.xml` file in the current directory. /!\ If the script fails after this point, make sure you delete this file to avoid having your credentials exposed /!\
- sign and deploy the artifacts with Apache Maven
- delete the `settings.xml` file
### Release artifacts
Once the artifacts have been deployed, you still need to release the repository.
- Go to the [Nexus Repository Manager](https://s01.oss.sonatype.org/)
- Login with your credentials
- Navigate to `Build Promotion` / `Staging Repositories`
- Select the `org.videolan` repository
![Nexus Repository Manager interface](images/nexus.png)
- Close it
- Wait for it to be closed
- Release it
When it's done, the artifacts should be available in Maven Central within a few minutes. To verify, you can navigate to:
- [libvlc](https://repo1.maven.org/maven2/org/videolan/android/libvlc-all/)
- [medialibrary](https://repo1.maven.org/maven2/org/videolan/android/medialibrary-all/)
After a few hours, they should also be available in the [Maven Search Engine](https://search.maven.org/search?q=g:org.videolan.android)
\ No newline at end of file
#!/bin/bash
set -euo pipefail
# Constants
OUTPUT_DIR="artifacts"
MEDIALIB_VERSION=""
LIBVLC_VERSION=""
# Utilities
function escape_pom() {
echo "$1" | sed 's#/#\\/#g' | tr '\n' '@'
}
function xml_encode() {
echo $1 | sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g'
}
function blue() {
echo -e "\033[1;34m===================\n$1\n===================\033[0m"
}
function purple() {
echo -e "\033[1;35m$1\033[0m"
}
function red() {
echo -e "\033[1;31m===================\n$1\n===================\033[0m"
}
#START
rm -rf $OUTPUT_DIR
mkdir -p $OUTPUT_DIR
blue "File management"
#check files
if test -f "dbg.zip"; then
blue "File exists. Unzipping"
unzip "dbg.zip" -d $OUTPUT_DIR
else
red "Cannot find the dbg.zip file."
exit 1
fi
blue "Files extracted"
blue "Looking for artifacts and versions"
if test -d "$OUTPUT_DIR/aars/repository/org/videolan/android/medialibrary-all"; then
MEDIALIB_VERSION=$(ls -tUd "$OUTPUT_DIR/aars/repository/org/videolan/android/medialibrary-all/"*/ | xargs basename)
else
red "Cannot find the medialibrary directory"
fi
if test -d "$OUTPUT_DIR/aars/repository/org/videolan/android/libvlc-all"; then
LIBVLC_VERSION=$(ls -tUd "$OUTPUT_DIR/aars/repository/org/videolan/android/libvlc-all/"*/ | xargs basename)
else
red "Cannot find the libvlc directory"
fi
purple "The following versions have been found.\nlibvlc: $LIBVLC_VERSION\nmedialibrary: $MEDIALIB_VERSION."
read -sp "Continue: y/N" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
[[ "$0" == "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
fi
blue "Ready to deploy"
read -p 'Enter your sonatype username: ' username
echo
SONATYPE_USERNAME=$(xml_encode $username)
read -sp 'Enter your sonatype password: ' pass
echo
SONATYPE_PASSWORD=$(xml_encode $pass)
blue "Setup Maven credentials"
echo "<settings xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd\">
<servers>
<server>
<id>ossrh</id>
<username>$SONATYPE_USERNAME</username>
<password>$SONATYPE_PASSWORD</password>
</server>
</servers>
</settings>" >settings.xml
if [ -z "$LIBVLC_VERSION" ]; then
purple "No version for libvlc. Skipping"
else
BASE_DIR="$OUTPUT_DIR/aars/repository/org/videolan/android/libvlc-all/$LIBVLC_VERSION"
blue "Deploying $BASE_DIR"
mvn gpg:sign-and-deploy-file \
--settings settings.xml \
-DpomFile=$BASE_DIR/libvlc-all-$LIBVLC_VERSION.pom \
-Dfile=$BASE_DIR/libvlc-all-$LIBVLC_VERSION.aar \
-Dsources=$BASE_DIR/libvlc-all-$LIBVLC_VERSION-sources.jar \
-Djavadoc=$BASE_DIR/libvlc-all-$LIBVLC_VERSION-javadoc.jar \
-Durl="https://s01.oss.sonatype.org/service/local/staging/deploy/maven2" \
-DgroupId=org.videolan.android \
-Dgpg.keyname=e8f8f982a0cd726f020ced90f4b3cd9a1faeefe8 \
-DrepositoryId=ossrh
fi
if [ -z "$MEDIALIB_VERSION" ]; then
purple "No version for medialibrary Skipping"
else
BASE_DIR="$OUTPUT_DIR/aars/repository/org/videolan/android/medialibrary-all/$MEDIALIB_VERSION"
blue "Deploying $BASE_DIR"
mvn gpg:sign-and-deploy-file \
--settings settings.xml \
-DpomFile=$BASE_DIR/medialibrary-all-$MEDIALIB_VERSION.pom \
-Dfile=$BASE_DIR/medialibrary-all-$MEDIALIB_VERSION.aar \
-Dsources=$BASE_DIR/medialibrary-all-$MEDIALIB_VERSION-sources.jar \
-Djavadoc=$BASE_DIR/medialibrary-all-$MEDIALIB_VERSION-javadoc.jar \
-Durl="https://s01.oss.sonatype.org/service/local/staging/deploy/maven2" \
-DgroupId=org.videolan.android \
-Dgpg.keyname=e8f8f982a0cd726f020ced90f4b3cd9a1faeefe8 \
-DrepositoryId=ossrh
fi
rm settings.xml
buildsystem/maven/images/nexus.png

105 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment