diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 0a02225..1b700f4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,9 @@ -name: build and test +name: Compliance check and build test -on: [push] +on: + push: + pull_request: + types: [ opened, reopened ] jobs: compliance: @@ -8,12 +11,28 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Advance Security Policy as Code - uses: advanced-security/policy-as-code@v2.7.0 + uses: advanced-security/policy-as-code@v2.4.1 with: policy: it-at-m/policy-as-code policy-path: default.yaml token: ${{ secrets.GITHUB_TOKEN }} argvs: "--disable-dependabot --disable-secret-scanning --disable-code-scanning --display" + + build-maven: + needs: compliance + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: "17" + distribution: "temurin" + cache: "maven" + + - name: Build with Maven + run: mvn --update-snapshots -f pom.xml verify \ No newline at end of file diff --git a/.github/workflows/publish-demo.yaml b/.github/workflows/publish-demo.yaml new file mode 100644 index 0000000..6c65bb4 --- /dev/null +++ b/.github/workflows/publish-demo.yaml @@ -0,0 +1,70 @@ +name: Build and publish to demo + +on: + workflow_dispatch: # execute manually + schedule: # it's important that the hour in the cron-job is after the hour of project_start_date in step calculate-time-passed + - cron: '0 13 * * 6' # execute automatically every Saturday at 13:00, change!! day of week if needed + +env: + SPRINT_LENGTH_IN_WEEKS: 3 + +jobs: + build-and-docker-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Get seconds passed since project start # project_start_date needs to be changed!! if different dispatch day is preferred + id: calculate-time-passed + run: | # 2023-10-28 is a Saturday and is used as the base for calculating the weeks passed + project_start_date=$(echo -n "2023-10-28 10:00") # it's important that the hour in this step is before the hour given in the cron-job + project_start_epoch_seconds=$(date -d "$project_start_date" +%s) + time_passed=$(($(date +"%s")-$project_start_epoch_seconds)) + echo "::set-output name=time_passed::$time_passed" + + - name: Get number of weeks passed + id: get-number-of-weeks + run: | # 604800 is 1 week in seconds + num_weeks_mod_sprint=$(((${{ steps.calculate-time-passed.outputs.time_passed }}/604800)%${{ env.SPRINT_LENGTH_IN_WEEKS }})) + echo "::set-output name=num_weeks_mod_sprint::$num_weeks_mod_sprint" + + - name: Check if job should be run # the automatically triggered actions should only be executed at the end of a sprint + if: github.event_name != 'workflow_dispatch' && steps.get-number-of-weeks.outputs.num_weeks_mod_sprint != 0 + run: | # canceling the job if the conditions weren't met, https://stackoverflow.com/a/75809743 + gh run cancel ${{ github.run_id }} + gh run watch ${{ github.run_id }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Git checkout to main branch # the workflow is triggered in the default branch, which doesn't have to be MAIN + uses: actions/checkout@v4 + with: { ref: main } # this also serves as a safeguard for workflows triggered manually + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build with Maven + run: mvn --update-snapshots -f pom.xml verify + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ghcr.io/it-at-m/mobidam-mobilithek-eai:demo \ No newline at end of file diff --git a/.github/workflows/publish-feature.yaml b/.github/workflows/publish-feature.yaml new file mode 100644 index 0000000..6901f5a --- /dev/null +++ b/.github/workflows/publish-feature.yaml @@ -0,0 +1,37 @@ +name: Build and publish to dev + +on: [workflow_dispatch] + +jobs: + build-and-docker-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build with Maven + run: mvn --update-snapshots -f pom.xml verify + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ghcr.io/it-at-m/mobidam-mobilithek-eai:dev \ No newline at end of file diff --git a/.github/workflows/publish-prod.yaml b/.github/workflows/publish-prod.yaml new file mode 100644 index 0000000..375b8fb --- /dev/null +++ b/.github/workflows/publish-prod.yaml @@ -0,0 +1,49 @@ +name: Build and publish to prod + +on: + workflow_dispatch: + inputs: + version: + description: 'Which version should be deployed to production?' + required: true + default: '0.0.1' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Git checkout to specific version + uses: actions/checkout@v4 + with: + ref: refs/tags/${{ github.event.inputs.version }} + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: "17" + distribution: "temurin" + cache: "maven" + + - name: Build with Maven + run: mvn -B verify -f pom.xml -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ghcr.io/it-at-m/mobidam-mobilithek-eai:prod diff --git a/.github/workflows/publish-test.yaml b/.github/workflows/publish-test.yaml new file mode 100644 index 0000000..80eb1c8 --- /dev/null +++ b/.github/workflows/publish-test.yaml @@ -0,0 +1,40 @@ +name: Build and publish to test + +on: + push: + branches: + - 'sprint' + +jobs: + build-and-docker-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build with Maven + run: mvn --update-snapshots -f pom.xml verify + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ghcr.io/it-at-m/mobidam-mobilithek-eai:test \ No newline at end of file diff --git a/.github/workflows/release-build.yaml b/.github/workflows/release-build.yaml new file mode 100644 index 0000000..caa0955 --- /dev/null +++ b/.github/workflows/release-build.yaml @@ -0,0 +1,108 @@ +name: Build release + +on: [workflow_dispatch] + +jobs: + release: + name: Release to registry + runs-on: ubuntu-latest + steps: + - name: Git checkout to main branch # Releases are published on main branch + uses: actions/checkout@v4 + with: { ref: main } + + - name: Install Java and Maven + uses: actions/setup-java@v3 + with: + java-version: "17" + distribution: "temurin" + cache: "maven" + + - name: Clean Maven Project Version + id: set-version + run: | + current_version=$(mvn help:evaluate -f pom.xml -Dexpression=project.version -q -DforceStdout) + echo "Current version: $current_version" + new_version=$(echo $current_version | sed 's/-SNAPSHOT//') + echo "New version: $new_version" + mvn -B versions:set -f pom.xml -DnewVersion=$new_version + git config --global user.email "github-actions@github.com" + git config --global user.name "GitHub Actions" + git add pom.xml + git commit -m "Bump main version to $new_version" + git push + echo "new_version=$new_version" >> $GITHUB_OUTPUT + + - name: Build with Maven + run: mvn -B verify -f pom.xml -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ghcr.io/it-at-m/mobidam-mobilithek-eai:${{ steps.set-version.outputs.new_version }}, ghcr.io/it-at-m/mobidam-mobilithek-eai:demo + + github-release: + needs: release + name: Create github release + runs-on: ubuntu-latest + steps: + - name: Git checkout to main branch # Releases are published on main branch + uses: actions/checkout@v4 + with: { ref: main } + + - name: Get New Project Version + id: get-version + run: | + current_version=$(mvn help:evaluate -f pom.xml -Dexpression=project.version -q -DforceStdout) + new_version=$(echo $current_version | sed 's/-SNAPSHOT//') + echo "New version: $new_version" + echo "new_version=$new_version" >> $GITHUB_OUTPUT + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.get-version.outputs.new_version }} + release_name: Release ${{ steps.get-version.outputs.new_version }} + draft: false + prerelease: false + + increase-snapshot: + needs: release + name: Increase patch-number of the SNAPSHOT-Version + runs-on: ubuntu-latest + steps: + - name: Git checkout to sprint branch # Snapshots are published on sprint branch + uses: actions/checkout@v4 + with: { ref: sprint } + + - name: Set Maven Project Version + id: set-version + run: | + current_version=$(mvn help:evaluate -f pom.xml -Dexpression=project.version -q -DforceStdout) + echo "Current version: $current_version" + new_version=$(echo $current_version | awk -F. -v OFS=. '{$3=$3+1; print $0"-SNAPSHOT"}') + echo "New version: $new_version" + mvn -B versions:set -DnewVersion=$new_version -f pom.xml + git config --global user.email "github-actions@github.com" + git config --global user.name "GitHub Actions" + git add pom.xml + git commit -m "Bump version to $new_version" + git push \ No newline at end of file diff --git a/.github/workflows/require-checklist.yaml b/.github/workflows/require-checklist.yaml new file mode 100644 index 0000000..ebdadfa --- /dev/null +++ b/.github/workflows/require-checklist.yaml @@ -0,0 +1,14 @@ +name: Require Checklist + +on: + pull_request: + types: [opened, edited, synchronize] + +jobs: + checklist-check: + runs-on: ubuntu-latest + if: ${{ github.actor != 'renovate[bot]' }} + steps: + - uses: mheap/require-checklist-action@v2 + with: + requireChecklist: true \ No newline at end of file diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 4c85493..a806d39 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,5 +1,9 @@ # Release-Notes +## Sprint 10 (16.04.2024 - 07.05.2024) +### Hinzugefügt +- Workflows erstellt + ## Sprint 9 (26.03.2024 - 16.04.2024) ### Hinzugefügt - Grundgerüst erstellt diff --git a/pom.xml b/pom.xml index 979a0df..74b95dc 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 @@ -23,24 +24,25 @@ 3.1.4 - 1.10.0 + 1.13.0 3.8.1 - 2.22.2 + 3.0.0-M5 3.9.0.2155 - 0.8.7 + 0.8.11 9.3 2.28.0 - 3.2.1 - 1.0.7 + 3.3.1 + 1.0.9 1.18.26 + UTF-8