chore(deps): Bump org.sonatype.central:central-publishing-maven-plugin #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# The workflow to deploy snapshot artifact versions to GitHub packages | |
# Fill free to adjust java version and additional mvn command-line parameters | |
# The workflow will trigger on pushes into branches different from main and release | |
# Please make sure that the version in the pom.xml file has the SNAPSHOT postfix | |
name: Maven GitHub deploy snapshot | |
on: | |
push: | |
branches-ignore: | |
- "main" | |
- "**release*" | |
- "prettier/**" | |
workflow_dispatch: | |
permissions: | |
packages: write | |
jobs: | |
mvn-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
- name: "Setup xmlstarlet" | |
run: | | |
sudo apt install -y xmlstarlet | |
- name: "Check that version is SNAPSHOT" | |
shell: bash | |
run: | | |
cd ${GITHUB_WORKSPACE} | |
IS_SNAPSHOT=$(xmlstarlet sel -N x="http://maven.apache.org/POM/4.0.0" -t -v "/x:project/x:properties/x:revision[contains(., '-SNAPSHOT')]" ./pom.xml || echo "") | |
if [[ "${IS_SNAPSHOT}" == "" ]] | |
then | |
echo "❗ The project/properties/revision in the pom.xml has no '-SNAPSHOT' postfix." >> $GITHUB_STEP_SUMMARY | |
echo "❗ Workflow fail. Please add '-SNAPSHOT' to the revision." >> $GITHUB_STEP_SUMMARY | |
echo "❗ The project/properties/revision in the pom.xml has '-SNAPSHOT' postfix." | |
echo "Workflow fail. Please add '-SNAPSHOT' to the revision." | |
exit 1 | |
else | |
echo "✅ The project/properties/revision in the pom.xml has '-SNAPSHOT' postfix: ${IS_SNAPSHOT}" >> $GITHUB_STEP_SUMMARY | |
echo "✅ The project/properties/revision in the pom.xml has '-SNAPSHOT' postfix: ${IS_SNAPSHOT}" | |
fi | |
- name: "Set up JDK" | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "21" | |
distribution: "temurin" | |
server-id: github | |
server-username: GITHUB_USER | |
server-password: GITHUB_TOKEN | |
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: Display settings.xml | |
run: cat ~/.m2/settings.xml | |
- name: "Disable Maven Central Deploy" | |
run: | | |
xmlstarlet ed -L -d "/_:project/_:build/_:plugins/_:plugin[./_:artifactId='central-publishing-maven-plugin']" ./pom.xml | |
- name: "Maven deploy" | |
run: | | |
mvn --batch-mode deploy -DaltDeploymentRepository=github::https://maven.pkg.github.com/${{ github.repository }} \ | |
-Dgpg.skip=true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_USER: ${{ github.actor }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} |