From a162f6032721c52dc900ed81e7f06a32333e5e72 Mon Sep 17 00:00:00 2001 From: Daniel Kocot Date: Fri, 26 Feb 2021 08:53:09 +0100 Subject: [PATCH] added GitHub Actions for build and release --- .github/workflows/maven-build.yml | 18 ++++++ .../workflows/release-to-maven-central.yml | 56 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 .github/workflows/maven-build.yml create mode 100644 .github/workflows/release-to-maven-central.yml diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml new file mode 100644 index 0000000..63c228a --- /dev/null +++ b/.github/workflows/maven-build.yml @@ -0,0 +1,18 @@ +name: Maven Build + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Build with Maven + run: mvn -B install --no-transfer-progress --file pom.xml diff --git a/.github/workflows/release-to-maven-central.yml b/.github/workflows/release-to-maven-central.yml new file mode 100644 index 0000000..d3a86da --- /dev/null +++ b/.github/workflows/release-to-maven-central.yml @@ -0,0 +1,56 @@ +name: release-to-maven-central +on: + workflow_dispatch: + inputs: + releaseversion: + description: 'Release version' + required: true + default: '1.1.0' +jobs: + publish: + runs-on: ubuntu-latest + steps: + - run: echo "Will start a Maven Central upload with version ${{ github.event.inputs.releaseversion }}" + + - uses: actions/checkout@v2 + + - name: Set up settings.xml for Maven Central Repository + uses: actions/setup-java@v1 + with: + java-version: 11 + server-id: oss.sonatype.org + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + + - name: Set projects Maven version to GitHub Action GUI set version + run: mvn versions:set "-DnewVersion=${{ github.event.inputs.releaseversion }}" --no-transfer-progress + + - name: Publish package + run: mvn --batch-mode clean deploy --no-transfer-progress -P central-deploy -DskipTests=true + env: + MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + + - name: Generate changelog + id: changelog + uses: metcalfc/changelog-generator@v0.4.4 + with: + myToken: ${{ secrets.GITHUB_TOKEN }} + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.event.inputs.releaseversion }} + release_name: ${{ github.event.inputs.releaseversion }} + body: | + Grab the new version from Maven central https://repo1.maven.org/maven2/de/codecentric/reedelk/reedelk-runtime/${{ github.event.inputs.releaseversion }}/ + ### Things that changed in this release + ${{ steps.changelog.outputs.changelog }} + draft: false + prerelease: false \ No newline at end of file