Maven Package #21
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
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created | |
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path | |
name: Maven Package | |
on: | |
workflow_dispatch: | |
inputs: | |
releaseversion: | |
description: 'Release version' | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Deploy JavaDoc 🚀 | |
uses: MathieuSoysal/[email protected] | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
javadoc-branch: master | |
java-version: 8 | |
target-folder: docs | |
project: maven | |
- name: Set up Maven Central Repository | |
uses: actions/setup-java@v1 | |
with: | |
java-version: '8' | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
gpg-private-key: ${{ secrets.OSSHR_GPG_SECRET_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
overwrite-settings: true | |
- name: Set projects Maven version to GitHub Action GUI set version | |
run: mvn versions:set "-DnewVersion=${{ github.event.inputs.releaseversion }}" | |
- name: Publish toMaven repository | |
run: mvn deploy --batch-mode --no-transfer-progress -P Release | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} | |
- name: Update readme.md | |
run: git fetch --unshallow; git pull; sed -i "s/$(git describe --tags --abbrev=0 | cut -c 2-)/${{ github.event.inputs.releaseversion }}/g" README.md | |
- uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Update POM version | |
file_pattern: 'pom.xml README.md' | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{ github.event.inputs.releaseversion }}" | |
release_name: "v${{ github.event.inputs.releaseversion }}" | |
body: | | |
Grab the new version from Maven central: | |
``` | |
<dependency> | |
<groupId>com.github.miachm.sods</groupId> | |
<artifactId>SODS</artifactId> | |
<version>${{ github.event.inputs.releaseversion }}</version> | |
</dependency> | |
``` | |
draft: false | |
prerelease: false |