diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 5f7f8ae..d6e12e7 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -1,9 +1,10 @@ name: Java CI -on: [push] - -permissions: - packages: write +on: + workflow_dispatch: + push: + pull_request: + branches: [ "master", "develop" ] jobs: build: @@ -16,11 +17,28 @@ jobs: uses: actions/setup-java@v1 with: java-version: 1.8 - - name: Build with Maven - run: mvn -B package --file pom.xml - - name: Deploy to Github Package Registry + server-id: sonatype-nexus-staging # Value of the distributionManagement/repository/id field of the pom.xml + server-username: CI_DEPLOY_USERNAME # env variable for username in deploy + server-password: CI_DEPLOY_PASSWORD # env variable for token in deploy + gpg-private-key: ${{ secrets.CI_GPG_PRIVATE_KEY }} # Value of the GPG private key to import + gpg-passphrase: CI_GPG_PASSPHRASE # env variable for GPG private key passphrase + + - name: install, unit test, integration test + run: mvn install -Dmaven.javadoc.skip=true -B -V + + - name: Release to maven central + if: github.ref_name == 'master' && github.event_name != 'pull_request' && github.repository == 'swisspost/jsons2xsd-maven-plugin' + run: | + curl -s https://get.sdkman.io | bash + source "$HOME/.sdkman/bin/sdkman-init.sh" + sdk install groovy 3.0.8 + + chmod +x ./maybe-release.sh + ./maybe-release.sh env: - GITHUB_USERNAME: x-access-token - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: - mvn --settings settings.xml deploy + CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} + CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} + CI_GPG_PASSPHRASE: ${{ secrets.CI_GPG_PASSPHRASE }} + + - name: After release + run: bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fc3351e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: java -dist: trusty -jdk: - - oraclejdk8 -before_install: - - chmod +x maybe-release.sh - # install groovy - - curl -s get.sdkman.io | bash - - source "$HOME/.sdkman/bin/sdkman-init.sh" - - sdk install groovy 3.0.8 - - echo $(groovy --version) -install: - - mvn install -Dmaven.javadoc.skip=true -B -V -before_script: - - git config --global user.email "swisspush@post.ch" - - git config --global user.name "Travis-CI" -script: - - git config credential.helper "store --file=.git/credentials" - - echo "https://${GH_TOKEN}:@github.com" > .git/credentials - - ./maybe-release.sh -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/maybe-release.sh b/maybe-release.sh index 550863a..601421e 100644 --- a/maybe-release.sh +++ b/maybe-release.sh @@ -1,42 +1,34 @@ #!/bin/bash set -ev -if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_REPO_SLUG" == "swisspush/jsons2xsd-maven-plugin" ] +git fetch +git reset --hard +groovy staging.groovy drop +rc=$? +if [ $rc -ne 0 ] then - git reset --hard - git clean -fd - git checkout master - echo 'Master checked out' - groovy staging.groovy drop + echo 'problem when trying to drop, ignored' +fi +echo 'starting a new nexus repository ...' +OUTPUT=$(groovy staging.groovy start) +echo "repository Id: $OUTPUT" +mvn -B -Prelease jgitflow:release-start jgitflow:release-finish -DrepositoryId=${OUTPUT} +rc=$? +if [ $rc -eq 0 ] +then + groovy staging.groovy close ${OUTPUT} + groovy staging.groovy promote ${OUTPUT} rc=$? if [ $rc -ne 0 ] then - echo 'problem when trying to drop, ignored' - fi - echo 'starting a new nexus repository ...' - OUTPUT=$(groovy staging.groovy start) - echo "repository Id: $OUTPUT" - mvn -B -Prelease -PpublicRepos jgitflow:release-start jgitflow:release-finish --settings settings.xml -DrepositoryId=${OUTPUT} - rc=$? - if [ $rc -eq 0 ] - then - groovy staging.groovy close ${OUTPUT} - groovy staging.groovy promote ${OUTPUT} - rc=$? - if [ $rc -ne 0 ] - then - echo 'Release failed, cannot promote stage' - exit rc - fi - echo 'Release done, will push' - git tag - git push --tags - git checkout develop - git push origin develop - exit 0 + echo 'Release failed, cannot promote stage' + exit $rc fi - echo 'Release failed' - exit rc -else - echo 'Release skipped' - exit 0 -fi \ No newline at end of file + echo 'Release done, will push' + git tag + git push --tags + git checkout develop + git push origin develop + exit 0 +fi +echo 'Release failed' +exit $rc diff --git a/pom.xml b/pom.xml index d99b3bb..f49e91d 100644 --- a/pom.xml +++ b/pom.xml @@ -82,6 +82,10 @@ ${session.executionRootDirectory} 230584D7 + + --pinentry-mode + loopback + @@ -229,6 +233,10 @@ ${session.executionRootDirectory} 230584D7 + + --pinentry-mode + loopback + diff --git a/settings.xml b/settings.xml deleted file mode 100644 index 76baf42..0000000 --- a/settings.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - github - - - - - github - - - central - https://repo1.maven.org/maven2 - - true - - - true - - - - github - GitHub OWNER Apache Maven Packages - https://maven.pkg.github.com/swisspush - - - - - - - - sonatype-nexus-staging - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - gpg.passphrase - ${env.CI_PGP_PASSWORD} - - - github - ${env.GITHUB_USERNAME} - ${env.GITHUB_TOKEN} - - - \ No newline at end of file