From a9934f2f440aa6d71db6d3c6c463fd6550ab44e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Dywicki?= Date: Wed, 31 Jan 2024 17:17:13 +0100 Subject: [PATCH] Add standardized CICD pipeline. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ɓukasz Dywicki --- .github/workflows/maven.yml | 48 ----------------- .github/workflows/pr.yml | 20 ++++++++ .github/workflows/push.yml | 20 ++++++++ .github/workflows/release.yml | 97 +++++++++++------------------------ pom.xml | 4 +- 5 files changed, 70 insertions(+), 119 deletions(-) delete mode 100644 .github/workflows/maven.yml create mode 100644 .github/workflows/pr.yml create mode 100644 .github/workflows/push.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index 4998076..0000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Maven build - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - build: - if: "!contains(github.event.commits[0].message, '[maven-release-plugin] prepare release')" - strategy: - matrix: - java: [ 11 ] - os: [ ubuntu-latest ] - fail-fast: false - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: 'temurin' - server-id: sonatype-nexus-snapshots - server-username: CI_DEPLOY_USERNAME - server-password: CI_DEPLOY_PASSWORD - - 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 - run: >- - mvn -B -fae clean verify - - name: Maven Deploy - if: github.event_name != 'pull_request' && success() - run: | - mvn deploy - env: - CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} - CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} - diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..4017034 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,20 @@ +name: Build pull request + +on: + pull_request: + branches: [ "master" ] + +jobs: + build: + permissions: + checks: write + contents: read + uses: 'connectorio/gh-actions-shared/.github/workflows/maven.yml@master' + secrets: + CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} + CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} + with: + openhab: false + server_id: thing4-snapshots + deploy: true + skip_test_publish: true \ No newline at end of file diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..7924580 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,20 @@ +name: Build pushed commit + +on: + push: + branches: [ "master" ] + +jobs: + build: + permissions: + checks: write + contents: read + uses: 'connectorio/gh-actions-shared/.github/workflows/maven.yml@master' + secrets: + CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} + CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} + with: + openhab: false + server_id: sonatype-nexus-snapshots + deploy: true + skip_test_publish: true \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3299fe3..0edcd00 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,77 +1,38 @@ -name: Maven release +name: Release artifacts on: workflow_dispatch: inputs: - releaseVersion: - description: "Release version." + release_version: + description: 'The version to be released from actual HEAD revision' + required: false + default: 'X.Y.Z' + development_version: + description: 'Version to be set as next, after release is made (appends commit to HEAD revision)' + required: false + default: 'X.Y.Z-SNAPSHOT' + perform_version: + description: 'Tag which should be used to perform release and publish its artifacts' + required: false + dry_run: + description: 'Should execution abstain from mutating repository/remote state?' 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" + default: 'true' jobs: - release: - runs-on: ubuntu-latest + build: 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: Dump env - run: >- - env && cat ~/.m2/settings.xml - env: - CI_RELEASE_USERNAME: ${{ secrets.CI_RELEASE_USERNAME }} - CI_RELEASE_PASSWORD: ${{ secrets.CI_RELEASE_PASSWORD }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - - 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 + uses: 'connectorio/gh-actions-shared/.github/workflows/release.yml@master' + secrets: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + CI_RELEASE_USERNAME: ${{ secrets.CI_RELEASE_USERNAME }} + CI_RELEASE_PASSWORD: ${{ secrets.CI_RELEASE_PASSWORD }} + with: + openhab: false + server_id: sonatype-nexus-staging + release_version: ${{ inputs.release_version }} + development_version: ${{ inputs.development_version }} + perform_version: ${{ inputs.perform_version }} + dry_run: ${{ inputs.dry_run }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index f5390bf..2b9da1d 100644 --- a/pom.xml +++ b/pom.xml @@ -23,11 +23,9 @@ org.connectorio connectorio-oss 5-SNAPSHOT - - ConnectorIO | OSS Parent pom - + ConnectorIO | OSS Parent Parent project for open source components developed by ConnectorIO. http://connectorio.org