diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 000000000..74fb37618 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,18 @@ +changelog: + categories: + - title: 🎉 New Features + labels: + - feature + - title: 🐞 Bug Fixes + labels: + - bug + - title: 🔨 Refactoring + labels: + - refactoring + - title: 📔 Documentation + labels: + - docs + - title: 🛠️ Misc + labels: + - Technical Debt + - chore diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d393e37b8..35a3b938b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,9 @@ jobs: release-version: dev snapshot-release: true maven-release: false - docker-release: ${{ github.ref_name == 'dev' }} + # FIXME rename the feat/new_platform branch + # docker-release: ${{ github.ref_name == 'dev' }} + docker-release: ${{ github.ref_name == 'feat/new_platform' }} secrets: inherit labelPR: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 5117e808c..000000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Build And Publish Application - -on: - workflow_dispatch: - inputs: - release-docker-image: - description: 'Release Docker Images using version specified in pom.xml (y/n)?' - required: true - default: 'y' - -jobs: - build-and-publish-docker-image: - if: github.event.inputs.release-docker-image == 'y' - runs-on: ubuntu-latest - steps: - - name: PREP / Checkout sources - uses: actions/checkout@v4 - - name: PREP / Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'corretto' - - name: PREP / Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: PREP / Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: PREP / Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_MIRAGON_USERNAME }} - password: ${{ secrets.DOCKER_MIRAGON_PASSWORD }} - - name: PREP / Set Release version env variable - run: | - echo "RELEASE_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV - # BUILD ALL SERVICES USING MAVEN - - name: BUILD / SERVICES / Execute Maven build - run: ./mvnw package - # BUILD TASKLIST-WEB-APP - - name: BUILD / APPS / Install dependencies - run: ./mvnw -f apps clean install - - name: BUILD / APPS / Build Tasklist-Web-App - run: ./mvnw -f apps -Pbuild - # DOCKERIZE & PUBLISH ALL IMAGES - - name: DOCKER / BUILD & PUBLISH / miragon/miranum-platform-engine-tasklist-service - uses: docker/build-push-action@v5 - with: - context: ./services/engine-tasklist-service/. - push: true - tags: miragon/miranum-platform-engine-tasklist-service:${{ env.RELEASE_VERSION }},miragon/miranum-platform-engine-tasklist-service:latest - platforms: linux/amd64, linux/arm64/v8 - - name: DOCKER / BUILD & PUBLISH / miragon/miranum-platform-schema-registry-service - uses: docker/build-push-action@v5 - with: - context: ./services/schema-registry-service/. - push: true - tags: miragon/miranum-platform-schema-registry-service:${{ env.RELEASE_VERSION }},miragon/miranum-platform-schema-registry-service:latest - platforms: linux/amd64, linux/arm64/v8 - - name: DOCKER / BUILD & PUBLISH / miragon/miranum-platform-deployment-service - uses: docker/build-push-action@v5 - with: - context: ./services/deployment-service/. - push: true - tags: miragon/miranum-platform-deployment-service:${{ env.RELEASE_VERSION }},miragon/miranum-platform-deployment-service:latest - platforms: linux/amd64, linux/arm64/v8 - - name: DOCKER / BUILD & PUBLISH / miragon/miranum-platform-s3-integration-service - uses: docker/build-push-action@v5 - with: - context: ./services/s3-integration-service/. - push: true - tags: miragon/miranum-platform-s3-integration-service:${{ env.RELEASE_VERSION }},miragon/miranum-platform-s3-integration-service:latest - platforms: linux/amd64, linux/arm64/v8 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..9377f7bca --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: Release + +on: + workflow_dispatch: + inputs: + release-tag: + description: 'Release Tag' + required: false + default: 'services_XXX_apps_XXX' + maven-new-version: + description: '(Optional) Specify new maven version - SNAPSHOT will be added to the version' + required: false + +jobs: + release-version: + runs-on: ubuntu-latest + steps: + - uses: PREP / actions/checkout@v4 + - name: PREP / Prepare mvnw + run: chmod +x ./mvnw + - name: PREP / Remove snapshot from services + run: ./mvnw versions:set --batch-mode -DremoveSnapshot -DprocessAllModules + - name: PREP / Set services release version env variable + run: echo "SERVICES_RELEASE_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV + outputs: + services-release-version: ${{ env.SERVICES_RELEASE_VERSION }} + + release-services: + needs: release-version + uses: ./.github/workflows/workflow-build-and-release-services.yml + with: + release-version: ${{ needs.release-version.outputs.services-release-version }} + snapshot-release: false + maven-release: true + docker-release: true + secrets: inherit + + github-release: + needs: release-services + uses: ./.github/workflows/workflow-github-release.yaml + with: + release-tag: ${{ github.event.inputs.release-tag }} + secrets: inherit + + bump-versions: + needs: github-release + uses: ./.github/workflows/workflow-bump-version.yaml + with: + new-maven-version: ${{ github.event.inputs.maven-new-version }} + secrets: inherit + diff --git a/.github/workflows/workflow-build-and-release-services.yml b/.github/workflows/workflow-build-and-release-services.yml index e3adc61f8..8847be0f3 100644 --- a/.github/workflows/workflow-build-and-release-services.yml +++ b/.github/workflows/workflow-build-and-release-services.yml @@ -54,14 +54,22 @@ jobs: chmod +x ./mvnw ./mvnw --batch-mode clean install - - name: RELEASE / Build and Release Maven + - name: RELEASE / Remove SNAPSHOT if: inputs.maven-release == true - # TODO other command run: | chmod +x ./mvnw - ./mvnw --batch-mode clean install + ./mvnw versions:set --batch-mode -DremoveSnapshot -DprocessAllModules + - name: RELEASE / Build and Release Maven + if: inputs.maven-release == true + uses: samuelmeuli/action-maven-publish@v1 + with: + gpg_private_key: ${{ secrets.pgp_private_key }} + gpg_passphrase: ${{ secrets.pgp_private_key_secret }} + nexus_username: ${{ secrets.nexus_username }} + nexus_password: ${{ secrets.nexus_password }} - name: DOCKER / BUILD & PUBLISH / miragon/miranum-camunda7-engine-service + if: inputs.docker-release == true uses: docker/build-push-action@v5 with: context: ./platform/services/miragon/camunda7-engine-service/. @@ -69,6 +77,7 @@ jobs: tags: miragon/miranum-camunda7-engine-service:${{ env.RELEASE_VERSION }} platforms: linux/amd64, linux/arm64/v8 - name: DOCKER / BUILD & PUBLISH / miragon/miranum-deployment-service + if: inputs.docker-release == true uses: docker/build-push-action@v5 with: context: ./platform/services/deployment-service/. diff --git a/.github/workflows/workflow-bump-version.yaml b/.github/workflows/workflow-bump-version.yaml new file mode 100644 index 000000000..6796e7c1c --- /dev/null +++ b/.github/workflows/workflow-bump-version.yaml @@ -0,0 +1,77 @@ +name: Bump version + +on: + workflow_call: + inputs: + new-maven-version: + description: 'New maven version' + type: string + required: false + workflow_dispatch: + inputs: + new-maven-version: + description: 'New maven version' + type: string + required: false + +jobs: + bump-versions: + name: Bumps versions + runs-on: ubuntu-latest + steps: + - name: PREP / Checkout code + uses: actions/checkout@v4 + - name: PREP / Setup git + run: | + git config --global user.email "miranum@miragon.de" + git config --global user.name "Miranum Github Bot" + - name: PREP / Prepare mvnw + run: chmod +x ./mvnw + - name: PREP / Install Java and Maven + if: inputs.bump-services-version== true + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'corretto' + + - name: BUMP VERSION / Raise mvn version + if: inputs.new-maven-version != '' + run: | + ./mvnw versions:set --batch-mode -DprocessAllModules -DnewVersion=${{ inputs.new-maven-version }}-SNAPSHOT -DprocessAllModules + ./mvnw versions:commit -DprocessAllModules + - name: BUMP VERSION / Raise mvn version + if: inputs.new-maven-version == '' + run: | + ./mvnw build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0-SNAPSHOT -DprocessAllModules + ./mvnw versions:commit -DprocessAllModules + - name: GIT / Git commit + run: | + git add . + git commit -m "chore: mvn auto version bump to $(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" + + - name: GIT / Push changes to new branch + run: | + git checkout -b ${{ github.ref_name }}-version-bump + git push --force origin ${{ github.ref_name }}-version-bump + - name: GIT / Create pull request + uses: actions/github-script@v7 + with: + script: | + const { repo, owner } = context.repo; + const pullResult = await github.rest.pulls.create({ + title: 'chore: bump release version ${{ github.ref_name }}', + owner, + repo, + head: '${{ github.ref_name }}-version-bump', + base: '${{ github.ref_name }}', + body: [ + 'This PR is auto-generated' + ].join('\n') + }); + await github.rest.issues.addAssignees({ + owner, + repo, + issue_number: pullResult.data.number, + assignees: ['${{ github.actor }}'], + }); + console.log(`Pull Request created: ${pullResult.data.html_url}`); diff --git a/.github/workflows/workflow-github-release.yaml b/.github/workflows/workflow-github-release.yaml new file mode 100644 index 000000000..920787595 --- /dev/null +++ b/.github/workflows/workflow-github-release.yaml @@ -0,0 +1,36 @@ +name: Github Release + +on: + workflow_call: + inputs: + release-tag: + description: 'Release tag' + type: string + required: true + +jobs: + github-release: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: PREP / Checkout code + uses: actions/checkout@v4 + + - name: GIT / Create tag + uses: actions/github-script@v7 + with: + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/${{ inputs.release-tag }}', + sha: context.sha + }) + - name: GIT / Create GitHub Release + id: create_release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ inputs.release-tag }} + draft: false + prerelease: false + generate_release_notes: true diff --git a/docs/CICD.md b/docs/CICD.md new file mode 100644 index 000000000..16046f13c --- /dev/null +++ b/docs/CICD.md @@ -0,0 +1,41 @@ +# CICD + +We use GitHub Actions for CICD Pipelines. The pipelines are defined in the `.github/workflows` directory. + +## Workflows + +### Build + +**Feature Branches** + +Build the project using Maven on each commit and PR to the `main` branch. + +```mermaid +graph LR + A[Checkout] --> B[Maven Build] +``` + +**Main Branch** + +Every new commit to the `main` branch builds the project using Maven and builds and releases Docker Images to Docker Hub with the tag `dev`. + +```mermaid +graph LR + A[Checkout] --> B[Maven Build] + B --> C[Docker Build and Push] +``` + +### Release + +Releases are triggered by dispatching the Release workflow manually. +The release workflow creates a new maven release and builds and releases Docker Images to Docker Hub with a version tag. +Additionally, a GitHub Release is created with auto generated release notes and finally the Maven version is bumped to the next snapshot version (or the version specified with the workflow dispatch). + +```mermaid +graph LR + A[Checkout] --> B[Maven Build and Release] + B --> C[Docker Build and Push] + C --> D[Github Release] + D --> E[Maven Version Bump] +``` +