diff --git a/.gitattributes b/.gitattributes index fcadb2cf97..e027140514 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,11 @@ * text eol=lf +# This file is broken and makes not sense as it is specified. +# It breaks the usage of git on linux based systems. Ignore crlf files +# which cannot be converted to lf. E.g. gradle wrapper conversion brakes +# the validation. +gradlew.bat -text +*.png -text +gradle-wrapper.jar -text +sample-war/src/main/webapp/WEB-INF/wiremock/__files/mytest.json -text +sample-war/src/main/webapp/WEB-INF/wiremock/mappings/mytest-mapping.json -text +src/test/resources/not-found-diff-sample_large_xml_jre11_windows.txt -text diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fb7837320b..0f1305ce06 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -22,6 +22,8 @@ updates: update-types: - "minor" - "patch" + commit-message: + prefix: "chore(deps)" - package-ecosystem: docker directory: "/" schedule: @@ -31,3 +33,5 @@ updates: open-pull-requests-limit: 20 assignees: - Author + commit-message: + prefix: "chore(deps)" diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000000..4ccab73671 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,4 @@ +bug: + - head-branch: ['^fix'] +enhancement: + - head-branch: ['^feat'] diff --git a/.github/release.yaml b/.github/release.yaml new file mode 100644 index 0000000000..3f97891bd0 --- /dev/null +++ b/.github/release.yaml @@ -0,0 +1,33 @@ +changelog: + exclude: + labels: + - ignore-for-release + categories: + - title: ๐Ÿšจ Security Updates + labels: + - security + - title: ๐Ÿ›  Breaking Changes + labels: + - breaking + - title: ๐Ÿ“ฆ Dependency updates + labels: + - dependencies + - title: ๐Ÿ› Bug fixes + labels: + - bug + - title: ๐ŸŽ‰ New Features + labels: + - enhancement + - title: ๐Ÿงช Test Updates + labels: + - test + - title: ๐Ÿ“– Documentation + labels: + - documentation + - title: ๐Ÿšง Build Tools + labels: + - ci + - build + - title: โ„น๏ธ Other Changes + labels: + - "*" diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 7172ff49e5..4b9c585a01 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -4,8 +4,6 @@ name: Build and Test on: - push: - branches: [ master ] pull_request: branches: [ master ] diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 2638addadc..9c0d28548f 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -4,9 +4,14 @@ name: Create Release on: - push: - tags: - - "*-ui" + schedule: + - cron: "0 9 * * *" + workflow_dispatch: + +env: + SEMANTIC_RELEASE_VERSION: 23.0.6 + SEMANTIC_RELEASE_EXEC_VERSION: 6.0.3 + CONVENTIONAL_COMMITS_VERSION: 7.0.2 jobs: build: @@ -25,56 +30,95 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set output - id: vars - run: | - echo "tag=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT - echo "version=$(echo $GITHUB_REF | cut -d / -f 3 | sed 's/.\{3\}$//')" >> $GITHUB_OUTPUT - - name: Check output - run: | - echo ${{ steps.vars.outputs.tag }} - echo ${{ steps.vars.outputs.version }} + - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v2 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Cache node modules + uses: actions/cache@v4 + id: cache-node-modules + with: + path: ~/.npm + key: ${{ runner.os }}-release-${{ env.SEMANTIC_RELEASE_VERSION }}-${{ env.SEMANTIC_RELEASE_EXEC_VERSION }}-${{ env.CONVENTIONAL_COMMITS_VERSION }} + + - name: Install Dependencies + shell: bash + run: | + #!/bin/bash + npm install -g semantic-release@${{ env.SEMANTIC_RELEASE_VERSION }} \ + @semantic-release/exec@${{ env.SEMANTIC_RELEASE_EXEC_VERSION }} \ + conventional-changelog-conventionalcommits@${{ env.CONVENTIONAL_COMMITS_VERSION }} + + - name: Determine Semver & Update PRs and Issues + id: semver + env: + GH_TOKEN: ${{ github.token }} + FORCE_COLOR: 1 + DEBUG_COLORS: 1 + run: | + #!/bin/bash + semantic-release --debug + - name: Set up JDK uses: actions/setup-java@v4 + if: steps.semver.outputs.version != '' with: java-version: ${{ matrix.jdk }} distribution: 'temurin' + - name: Grant execute permission for gradlew + if: steps.semver.outputs.version != '' run: chmod +x gradlew + - name: Cache Gradle packages uses: actions/cache@v4 + if: steps.semver.outputs.version != '' with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: ${{ runner.os }}-gradle + - name: Build - run: ./gradlew jar shadowJar + if: steps.semver.outputs.version != '' + run: ./gradlew jar shadowJar -PprojVersion=${{ steps.semver.outputs.version }} + - name: Create Release - id: create_release - uses: actions/create-release@v1 + id: create-release + shell: bash + if: steps.semver.outputs.version != '' env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.vars.outputs.tag }} - release_name: ${{ steps.vars.outputs.version }} - body_path: RELEASE-NOTES.md - draft: false - prerelease: false + GH_TOKEN: ${{ github.token }} + run: | + #!/bin/bash + gh api \ + --method POST \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{ github.repository }}/releases \ + -f tag_name='${{ steps.semver.outputs.version }}' \ + -f target_commitish='${{ github.sha }}' \ + -f name='${{ steps.semver.outputs.version }}' \ + -F draft=false \ + -F prerelease=false \ + -F generate_release_notes=true + - name: Upload Release Asset id: upload-release-asset - uses: actions/upload-release-asset@v1 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./build/libs/wiremock-standalone-${{ steps.vars.outputs.version }}.jar - asset_name: wiremock-standalone-${{ steps.vars.outputs.version }}.jar - asset_content_type: application/java-archive + GH_TOKEN: ${{ github.token }} + shell: bash + if: steps.semver.outputs.version != '' + run: | + gh release upload ${{ steps.semver.outputs.version }} ./build/libs/wiremock-standalone-${{ steps.semver.outputs.version }}.jar#wiremock-standalone-${{ steps.semver.outputs.version }}.jar + docker: needs: [build] uses: ./.github/workflows/docker-release.yml + if: needs.build.outputs.version != '' with: version: ${{ needs.build.outputs.version }} secrets: diff --git a/.github/workflows/docker-image-scan.yml b/.github/workflows/docker-image-scan.yml index ea38e8c2c1..c1a9f16035 100644 --- a/.github/workflows/docker-image-scan.yml +++ b/.github/workflows/docker-image-scan.yml @@ -29,7 +29,7 @@ jobs: id: extract-version run: | tag=${{ steps.extract-release.outputs.release }} - version=${tag%-*} + version=${tag} echo $version echo "version=${version}" >> $GITHUB_OUTPUT @@ -48,10 +48,8 @@ jobs: name: Ignore some policies run: | cat > .trivyignore << EOL - # Ignore gosu issue. They say they are not affected. Issue will be removed as soon - # as wiremock image updates to a newer gosu version, which removed runc. - CVE-2023-27561 - CVE-2024-21626 + # Ignore false-positives like this: + # CVE-2023-27561 EOL - uses: actions/cache@v4 with: diff --git a/.github/workflows/labeler.yaml b/.github/workflows/labeler.yaml new file mode 100644 index 0000000000..580644f06d --- /dev/null +++ b/.github/workflows/labeler.yaml @@ -0,0 +1,20 @@ +name: "Pull Request Labeler" +on: + pull_request: + branches-ignore: + # dependabot labels automatically already + - dependabot/** + +jobs: + labeler: + name: Label Pull requests + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 + env: + GH_TOKEN: ${{ github.token }} + with: + sync-labels: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index bbd79762f1..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Release - -on: - workflow_dispatch: - -jobs: - publish: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v3 - - name: Set up Java - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 - - - name: Publish package - id: publish_package - uses: gradle/gradle-build-action@v2.9.0 - with: - arguments: publish closeAndReleaseStagingRepository addGitTag --stacktrace - - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} - OSSRH_GPG_SECRET_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }} - OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} diff --git a/.github/workflows/validate-gradle-wrapper.yml b/.github/workflows/validate-gradle-wrapper.yml index b023badbcd..7f222a5453 100644 --- a/.github/workflows/validate-gradle-wrapper.yml +++ b/.github/workflows/validate-gradle-wrapper.yml @@ -4,8 +4,6 @@ name: Validate Gradle wrapper on: - push: - branches: [ master ] pull_request: branches: [ master ] diff --git a/.releaserc.yaml b/.releaserc.yaml new file mode 100644 index 0000000000..c5140ff7f2 --- /dev/null +++ b/.releaserc.yaml @@ -0,0 +1,44 @@ +branches: [ "master" ] +repositoryUrl: "git@github.com:holomekc/wiremock.git" +tagFormat: ${version} +plugins: + # https://github.com/semantic-release/semantic-release/blob/master/docs/extending/plugins-list.md + - "@semantic-release/commit-analyzer" + - "@semantic-release/exec" + - "@semantic-release/github" +dryRun: false +ci: true + +analyzeCommits: + # https://github.com/semantic-release/commit-analyzer + - path: "@semantic-release/commit-analyzer" + preset: "conventionalcommits" + # Default rules: https://github.com/semantic-release/commit-analyzer/blob/master/lib/default-release-rules.js + # releaseRules: + # - type: "feat" + # release: "patch" + +verifyRelease: + - path: "@semantic-release/exec" + verifyReleaseCmd: | + #!/bin/bash + echo "version=${nextRelease.version}" >> "$GITHUB_OUTPUT" || echo "Most likely no ci env. Skipping export of ${nextRelease.version}" + +generateNotes: false +publish: false + +success: + - path: "@semantic-release/exec" + successCmd: | + #!/bin/bash + ./release-tags.sh "${nextRelease.version}" + + - path: "@semantic-release/github" + successComment: | + :tada: This <%= issue.pull_request ? 'pull request' : 'issue' %> is included in version <%= '[' + nextRelease.version + '](https://github.com/holomekc/wiremock/releases/tag/' + nextRelease.version + ')' %> + +fail: + - path: "@semantic-release/github" + labels: false + assignees: + - "@holomekc" diff --git a/alpine/Dockerfile b/alpine/Dockerfile index e38708fa88..63e282ede2 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -1,4 +1,4 @@ -FROM wiremock/wiremock:latest-alpine +FROM wiremock/wiremock:3.5.2-1-alpine LABEL maintainer="Christopher Holomek " LABEL org.label-schema.name="wiremock-gui" diff --git a/build.gradle b/build.gradle index a8a123cce3..3311a8ca6b 100644 --- a/build.gradle +++ b/build.gradle @@ -220,7 +220,11 @@ allprojects { mavenCentral() } - version = '3.4.2.0' + if (project.hasProperty('projVersion')) { + version = project.projVersion + } else { + version = '1.0.0-Snapshot' + } sourceCompatibility = 11 diff --git a/release-tags.sh b/release-tags.sh new file mode 100755 index 0000000000..3be9fe6c15 --- /dev/null +++ b/release-tags.sh @@ -0,0 +1,11 @@ +#!/bin/bash +major=$(echo "${1}" | cut -d. -f1) +minor=$(echo "${1}" | cut -d. -f2) + +echo "Update minor tag: ${major}.${minor}" +git tag "${major}.${minor}" --force +git push origin "${major}.${minor}" --force + +echo "Update major tag: ${major}" +git tag "${major}" --force +git push origin "${major}" --force