Skip to content

Release Extension to Sonatype #53

Release Extension to Sonatype

Release Extension to Sonatype #53

name: Release Extension to Sonatype
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Release Tag'
required: true
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.collect-data.outputs.tag }}
version: ${{ steps.collect-data.outputs.version }}
steps:
- name: Collect Data
id: collect-data
uses: actions/github-script@v6
with:
script: |
let tag;
if (context.payload.inputs) {
tag = context.payload.inputs.tag;
} else {
tag = context.payload.release.tag_name;
}
let version = tag.replace(/^v/, "");
core.setOutput("tag", tag);
core.setOutput("version", version);
- run: |
echo "Publishing version ${{ steps.collect-data.outputs.version }} from ${{ steps.collect-data.outputs.tag }}"
deploy_maven:
name: Deploy to Maven
needs: [ setup ]
runs-on: ubuntu-latest
steps:
- name: Download Release Artifacts
uses: robinraju/[email protected]
with:
tag: "${{ needs.setup.outputs.tag }}"
filename: "*"
out-file-path: "."
- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
server-id: sonatype-nexus-staging
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Publish to Maven Central
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.SONATYPE_TOKEN }}
run: |
version=${{ needs.setup.outputs.version }}
unzip *.zip
mvn -B org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy-file \
-Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
-DrepositoryId=sonatype-nexus-staging \
-DpomFile=liquibase-hibernate5-${version}.pom \
-DgeneratePom=false \
-Dfile=liquibase-hibernate5-${version}.jar \
-Dsources=liquibase-hibernate5-${version}-sources.jar \
-Djavadoc=liquibase-hibernate5-${version}-javadoc.jar \
-Dfiles=liquibase-hibernate5-${version}.jar.asc,liquibase-hibernate5-${version}-sources.jar.asc,liquibase-hibernate5-${version}-javadoc.jar.asc,liquibase-hibernate5-${version}.pom.asc \
-Dtypes=jar.asc,jar.asc,jar.asc,pom.asc \
-Dclassifiers=,sources,javadoc,