From add56b098c351508d5e5aae5f9530339e9ea1214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Dywicki?= Date: Mon, 30 Oct 2023 22:05:28 +0100 Subject: [PATCH] Migrate CI/CD to github workflows/actions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ɓukasz Dywicki --- .circleci/config.yml | 28 -------------- .github/workflows/maven.yml | 46 +++++++++++++++++++++++ .github/workflows/release.yml | 70 +++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 28 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/maven.yml create mode 100644 .github/workflows/release.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 1adf638..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,28 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: circleci/openjdk:8-jdk - - working_directory: ~/repo - - environment: - # Customize the JVM maximum heap limit - MAVEN_OPTS: -Xmx256m - - steps: - - checkout - - restore_cache: - keys: - - v1-dependencies-{{ checksum "pom.xml" }} - - v1-dependencies- - - - run: mvn package dependency:go-offline - - - save_cache: - paths: - - ~/.m2 - key: v1-dependencies-{{ checksum "pom.xml" }} - - # run tests! - - run: mvn integration-test \ No newline at end of file diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..f509d6f --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,46 @@ +name: Maven build + +on: + push: + branches: [ "master", "1.0.x" , "1.1.x" , "1.2.x" , "1.3.x" ] + pull_request: + branches: [ "master", "1.0.x" , "1.1.x" , "1.2.x" , "1.3.x" ] + +jobs: + build: + permissions: + checks: write + contents: read + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: 'temurin' + - name: Cache local Maven repository + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Build with Maven + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: >- + mvn -B -fae -nsu clean verify + - name: Upload Test Report + uses: actions/upload-artifact@v3 + if: success() || failure() + with: + name: "java-test-report" + path: | + **/surefire-reports/TEST-*.xml + **/failsafe-reports/TEST-*.xml + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..da423ce --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,70 @@ +name: Maven release + +on: + workflow_dispatch: + inputs: + releaseVersion: + description: "Release version." + required: true + default: "X.Y.Z" + developmentVersion: + description: "Version to which working copy should be set after release." + required: true + default: "X.Y.Z-SNAPSHOT" + dryRun: + description: "Should release be done in dry-run mode." + required: true + default: "true" + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - name: Setup git + run: | + git config user.email "ci@connectorio.com" + git config user.name "ConnectorIO Bot" + git config --global url."https://${BUILD_USER}:${BUILD_TOKEN}@github.com/".insteadOf "git@github.com:" + env: + BUILD_USER: x-access-token + BUILD_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + server-id: sonatype-nexus-staging + server-username: CI_RELEASE_USERNAME + server-password: CI_RELEASE_PASSWORD + gpg-passphrase: GPG_PASSPHRASE + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + - name: Cache local Maven repository + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Maven Prepare Release + run: >- + mvn -B + release:prepare -DpreparationProfiles=release + -DreleaseVersion=${{ inputs.releaseVersion }} + -DdevelopmentVersion=${{ inputs.developmentVersion }} + -DdryRun=${{ inputs.dryRun }} + - name: Maven Perform Release + if: success() + run: >- + mvn -B + release:perform -DreleaseProfiles=release + env: + CI_RELEASE_USERNAME: ${{ secrets.CI_RELEASE_USERNAME }} + CI_RELEASE_PASSWORD: ${{ secrets.CI_RELEASE_PASSWORD }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + - name: Rollback on failure + if: failure() + run: | + mvn -B release:rollback + echo "You may need to manually delete the git tag, if it was created." \ No newline at end of file