From 55dd8ce7a84806dad11324b7bf81dcaf4eb13e47 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sat, 27 Jan 2024 16:02:18 +0100 Subject: [PATCH 01/15] Update dependencies --- .github/workflows/build.yml | 29 +++++------ .github/workflows/codeql-analysis.yml | 30 +++++------ .settings/org.eclipse.jdt.core.prefs | 1 + .vscode/settings.json | 13 +++++ README.md | 69 -------------------------- doc/developer_guide/developer_guide.md | 66 ++++++++++++++++++------ pom.xml | 51 +++++++++++++------ 7 files changed, 125 insertions(+), 134 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f32df0..d6d655b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: Build on: push: - branches: [ master, develop ] + branches: [ main ] pull_request: - branches: [ master, develop ] + branches: [ main ] jobs: build: @@ -12,30 +12,25 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Fetch all history for all tags and branches - run: git fetch --prune --unshallow - - uses: actions/setup-java@v1 + - uses: actions/checkout@v4 with: - java-version: 11 - - name: Cache local Maven repository - uses: actions/cache@v2 + fetch-depth: 0 + - uses: actions/setup-java@v4 with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- + cache: maven + distribution: temurin + java-version: | + 11 + 17 + 21 - name: Build with Maven run: mvn --errors --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install - env: - MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn" - name: Sonar if: ${{ env.SONAR_TOKEN != null }} - run: mvn --errors --batch-mode "-Dsonar.host.url=https://sonarcloud.io" -Dsonar.organization=itsallcode -Dsonar.login=$SONAR_TOKEN sonar:sonar + run: mvn --errors --batch-mode -Dsonar.token=$SONAR_TOKEN sonar:sonar env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn" - name: Publish Test Report uses: scacap/action-surefire-report@v1 if: always() diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index a385c7c..2ab060c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,11 +2,9 @@ name: "CodeQL" on: push: - branches: [develop, master] + branches: [main] pull_request: - branches: [develop, master] - schedule: - - cron: '0 4 * * 3' + branches: [main] jobs: analyze: @@ -18,27 +16,23 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-java@v1 + - uses: actions/setup-java@v4 with: - java-version: 11 - - - name: Cache local Maven repository - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- + cache: maven + distribution: temurin + java-version: | + 11 + 17 - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v3 with: languages: java - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v3 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index b3c482a..fcbcd7a 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -22,6 +22,7 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=11 org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3800052 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "modifications", + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit", + "source.generate.finalModifiers": "explicit", + "source.fixAll": "explicit" + }, + "java.saveActions.organizeImports": true, + "java.sources.organizeImports.starThreshold": 3, + "java.sources.organizeImports.staticStarThreshold": 3, + "java.configuration.updateBuildConfiguration": "automatic", +} \ No newline at end of file diff --git a/README.md b/README.md index 35e6303..e6cb066 100644 --- a/README.md +++ b/README.md @@ -62,72 +62,3 @@ The Hamcrest Multiline Text Matcher requires Java 11 to run. | [Maven Surefire Plugin](https://maven.apache.org/surefire/maven-surefire-plugin/) | Unit testing | Apache License 2.0 | | [OSS Index Maven Plugin](https://sonatype.github.io/ossindex-maven/maven-plugin/) | Checking Dependencies Vulnerability | ASL2 | | [Versions Maven Plugin](https://www.mojohaus.org/versions-maven-plugin/) | Checking if dependencies updates are available | Apache License 2.0 | - -## Development - - -### Generate / update license file header - -```bash -mvn license:update-file-header -``` - -## Run local sonar analysis - -```bash -mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.organization=itsallcode \ - -Dsonar.login=[token] -``` - -See analysis results at https://sonarcloud.io/dashboard?id=org.itsallcode%3Ahamcrest-mutliline-text-matcher - -## Check for updated dependencies / plugins - -```bash -mvn versions:display-dependency-updates -``` - -```bash -mvn versions:display-plugin-updates -``` - -### Publishing to JCenter - -1. Add the following to your `~/.m2/settings.xml`: - - ```xml - - - - ossrh - your-jira-id - your-jira-pwd - - - - - ossrh - - true - - - gpg - the_pass_phrase - - - - - ``` - -1. Checkout the `master` branch. -1. Update version in `pom.xml`, commit and push. -1. Run command - - ```bash - mvn -DskipSigningArtifacts=false clean deploy - ``` - -1. Create a [release](https://github.com/itsallcode/hamcrest-mutliline-text-matcher/releases) of the `master` branch on GitHub. -1. After some time the release will be available at [Maven Central](https://repo1.maven.org/maven2/org/itsallcode/hamcrest-mutliline-text-matcher/). diff --git a/doc/developer_guide/developer_guide.md b/doc/developer_guide/developer_guide.md index 018a906..f4e4fa0 100644 --- a/doc/developer_guide/developer_guide.md +++ b/doc/developer_guide/developer_guide.md @@ -1,29 +1,65 @@ # Developer Guide -## Publishing to JCenter +## Generate / update license file header + +```bash +mvn license:update-file-header +``` + +## Run local sonar analysis + +```bash +mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar \ + -Dsonar.token=[token] +``` + +See analysis results at https://sonarcloud.io/dashboard?id=org.itsallcode%3Ahamcrest-mutliline-text-matcher + +## Check for updated dependencies / plugins + +```bash +mvn versions:display-dependency-updates +``` + +```bash +mvn versions:display-plugin-updates +``` + +## Publishing to Maven Central 1. Add the following to your `~/.m2/settings.xml`: ```xml - - - bintray-maven-repo - [bintray-username] - [bintray-api-key] - - + + + + ossrh + your-jira-id + your-jira-pwd + + + + + ossrh + + true + + + gpg + the_pass_phrase + + + + ``` -1. Checkout the `master` branch. +1. Checkout the `main` branch. 1. Update version in `pom.xml`, commit and push. 1. Run command ```bash - mvn deploy + mvn -DskipSigningArtifacts=false clean deploy ``` -1. Create a [release](https://github.com/itsallcode/hamcrest-mutliline-text-matcher/releases) on GitHub. -1. Sign in at [bintray.com](https://bintray.com/login?forwardedFrom=%2Fitsallcode%2Fitsallcode%2Fhamcrest-mutliline-text-matcher) -1. Go to the [bintray project page](https://bintray.com/itsallcode/itsallcode/hamcrest-mutliline-text-matcher) -1. There should be a notice saying "You have 16 unpublished item(s) for this package". Click the "Publish" link. Binaries will be available for download at [jcenter](https://jcenter.bintray.com/org/itsallcode/hamcrest-mutliline-text-matcher/) -1. Publish to Maven Central by clicking the "Sync" button at [the project page](https://bintray.com/itsallcode/itsallcode/hamcrest-mutliline-text-matcher#central). After some time the new version will appear at [Maven Central](https://repo1.maven.org/maven2/org/itsallcode/hamcrest-mutliline-text-matcher/). +1. Create a [release](https://github.com/itsallcode/hamcrest-mutliline-text-matcher/releases) of the `main` branch on GitHub. +1. After some time the release will be available at [Maven Central](https://repo1.maven.org/maven2/org/itsallcode/hamcrest-mutliline-text-matcher/). diff --git a/pom.xml b/pom.xml index bd1cb98..275c0d2 100644 --- a/pom.xml +++ b/pom.xml @@ -10,12 +10,14 @@ UTF-8 11 true + https://sonarcloud.io + itsallcode org.junit.jupiter junit-jupiter - 5.7.0 + 5.10.1 test @@ -26,10 +28,29 @@ + + org.apache.maven.plugins + maven-toolchains-plugin + 3.1.0 + + + + toolchain + + + + + + + ${java.version} + + + + org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.12.1 ${java.version} ${java.version} @@ -38,7 +59,7 @@ org.codehaus.mojo license-maven-plugin - 2.0.0 + 2.4.0 false true @@ -73,17 +94,17 @@ org.apache.maven.plugins maven-jar-plugin - 3.2.0 + 3.3.0 org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M5 + 3.2.5 org.apache.maven.plugins maven-source-plugin - 3.2.1 + 3.3.0 attach-sources @@ -96,7 +117,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.2.0 + 3.6.3 attach-javadocs @@ -117,7 +138,7 @@ org.jacoco jacoco-maven-plugin - 0.8.6 + 0.8.11 @@ -136,7 +157,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.0.0-M3 + 3.4.1 enforce-maven @@ -146,7 +167,7 @@ - 3.5.4 + 3.6.3 @@ -156,7 +177,7 @@ org.codehaus.mojo versions-maven-plugin - 2.8.1 + 2.16.2 package @@ -170,7 +191,7 @@ org.sonatype.ossindex.maven ossindex-maven-plugin - 3.1.0 + 3.2.0 package @@ -183,7 +204,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.6 + 3.1.0 sign-artifacts @@ -200,12 +221,12 @@ org.apache.maven.plugins maven-deploy-plugin - 2.8.2 + 3.1.1 org.sonatype.plugins nexus-staging-maven-plugin - 1.6.8 + 1.6.13 true ossrh From 29788151f22ee6ac823385654939cbd5ed563ae5 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sat, 27 Jan 2024 16:06:25 +0100 Subject: [PATCH 02/15] Configure build with other Java versions --- .github/workflows/build.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d6d655b..debd7be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,9 +7,15 @@ on: branches: [ main ] jobs: - build: - + matrix-build: runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + java: [11, 17, 21] + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-java-${{ matrix.java }} + cancel-in-progress: true steps: - uses: actions/checkout@v4 @@ -24,9 +30,9 @@ jobs: 17 21 - name: Build with Maven - run: mvn --errors --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install + run: mvn --errors --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Djava.version=${{ matrix.java }} - name: Sonar - if: ${{ env.SONAR_TOKEN != null }} + if: ${{ env.DEFAULT_JAVA == matrix.java && env.SONAR_TOKEN != null }} run: mvn --errors --batch-mode -Dsonar.token=$SONAR_TOKEN sonar:sonar env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 5193e769be8fb45775e821dce5a9f1eee2b932fc Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sat, 27 Jan 2024 16:08:46 +0100 Subject: [PATCH 03/15] Add default java version --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index debd7be..3dc9e71 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,8 @@ jobs: concurrency: group: ${{ github.workflow }}-${{ github.ref }}-java-${{ matrix.java }} cancel-in-progress: true + env: + DEFAULT_JAVA: 11 steps: - uses: actions/checkout@v4 From 2c5cbb7af7e71181820d572436dc295f697d10af Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sat, 27 Jan 2024 16:13:15 +0100 Subject: [PATCH 04/15] Fix javadoc for Java 21 --- .github/workflows/build.yml | 2 +- pom.xml | 6 +++++- .../java/org/itsallcode/matcher/MultilineTextMatcher.java | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3dc9e71..081d507 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: 11 17 21 - - name: Build with Maven + - name: Build with Java ${{ matrix.java }} run: mvn --errors --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Djava.version=${{ matrix.java }} - name: Sonar if: ${{ env.DEFAULT_JAVA == matrix.java && env.SONAR_TOKEN != null }} diff --git a/pom.xml b/pom.xml index 275c0d2..4dedae0 100644 --- a/pom.xml +++ b/pom.xml @@ -131,7 +131,11 @@ true true - false + true + false + + -html5 + ${java.version} diff --git a/src/main/java/org/itsallcode/matcher/MultilineTextMatcher.java b/src/main/java/org/itsallcode/matcher/MultilineTextMatcher.java index 6745ec2..f5e3f40 100644 --- a/src/main/java/org/itsallcode/matcher/MultilineTextMatcher.java +++ b/src/main/java/org/itsallcode/matcher/MultilineTextMatcher.java @@ -41,6 +41,11 @@ public class MultilineTextMatcher extends TypeSafeMatcher private static final String LINE_ENDING = "\\r\\n|\\r|\\n"; private final String originalText; + /** + * Create a new instance. + * + * @param originalText the original text + */ public MultilineTextMatcher(final String originalText) { this.originalText = originalText; From a2000dee47bb8f4eff70bcabdb522286a07c4a00 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sat, 27 Jan 2024 16:14:10 +0100 Subject: [PATCH 05/15] Add default build --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 081d507..488b84c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -45,3 +45,10 @@ jobs: with: report_paths: '**/target/surefire-reports/TEST-*.xml' github_token: ${{ secrets.GITHUB_TOKEN }} + + + build: + needs: matrix-build + runs-on: ubuntu-latest + steps: + - run: echo "Build successful" From eda8ae81575d847927c05d2429fcab4c5948f234 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sat, 27 Jan 2024 16:39:20 +0100 Subject: [PATCH 06/15] Add sonar binding --- .vscode/settings.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3800052..1c5a1c6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,4 +10,8 @@ "java.sources.organizeImports.starThreshold": 3, "java.sources.organizeImports.staticStarThreshold": 3, "java.configuration.updateBuildConfiguration": "automatic", + "sonarlint.connectedMode.project": { + "connectionId": "itsallcode", + "projectKey": "org.itsallcode:hamcrest-mutliline-text-matcher" + } } \ No newline at end of file From 329e2427902811e27896c52598f1448551dba3e4 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sun, 1 Sep 2024 16:33:56 +0200 Subject: [PATCH 07/15] Upgrade plugins --- pom.xml | 85 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index 4dedae0..a1c70aa 100644 --- a/pom.xml +++ b/pom.xml @@ -12,26 +12,49 @@ true https://sonarcloud.io itsallcode + ${git.commit.time} + ${reproducible.build.timestamp} - org.junit.jupiter - junit-jupiter - 5.10.1 - test + org.hamcrest + hamcrest + 3.0 - org.hamcrest - hamcrest-all - 1.3 + org.junit.jupiter + junit-jupiter-api + 5.11.0 + test + + io.github.git-commit-id + git-commit-id-maven-plugin + 9.0.1 + + + get-the-git-infos + + revision + + initialize + + + + true + false + + git.commit.time + + + org.apache.maven.plugins maven-toolchains-plugin - 3.1.0 + 3.2.0 @@ -50,10 +73,15 @@ org.apache.maven.plugins maven-compiler-plugin - 3.12.1 + 3.13.0 ${java.version} ${java.version} + true + + -Xlint:all + -Werror + @@ -94,17 +122,17 @@ org.apache.maven.plugins maven-jar-plugin - 3.3.0 + 3.4.2 org.apache.maven.plugins maven-surefire-plugin - 3.2.5 + 3.5.0 org.apache.maven.plugins maven-source-plugin - 3.3.0 + 3.3.1 attach-sources @@ -117,7 +145,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.6.3 + 3.10.0 attach-javadocs @@ -142,7 +170,7 @@ org.jacoco jacoco-maven-plugin - 0.8.11 + 0.8.12 @@ -161,7 +189,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.4.1 + 3.5.0 enforce-maven @@ -181,7 +209,7 @@ org.codehaus.mojo versions-maven-plugin - 2.16.2 + 2.17.1 package @@ -208,7 +236,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.2.5 sign-artifacts @@ -225,12 +253,12 @@ org.apache.maven.plugins maven-deploy-plugin - 3.1.1 + 3.1.3 org.sonatype.plugins nexus-staging-maven-plugin - 1.6.13 + 1.7.0 true ossrh @@ -238,6 +266,23 @@ true + + org.apache.maven.plugins + maven-artifact-plugin + 3.5.1 + + + verify-reproducible-build + verify + + check-buildplan + + + + + true + + https://github.com/itsallcode/hamcrest-mutliline-text-matcher @@ -280,4 +325,4 @@ https://oss.sonatype.org/service/local/staging/deploy/maven2/ - \ No newline at end of file + From 57276f75c592996a9431ca232436753f07bf95db Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sun, 1 Sep 2024 16:43:16 +0200 Subject: [PATCH 08/15] Prepare automatic release --- .github/workflows/build.yml | 9 +---- .github/workflows/github_release.sh | 30 ++++++++++++++ .github/workflows/release.yml | 63 +++++++++++++++++++++++++++++ doc/changes/changes_2.0.1.md | 18 +++++++++ 4 files changed, 113 insertions(+), 7 deletions(-) create mode 100755 .github/workflows/github_release.sh create mode 100644 .github/workflows/release.yml create mode 100644 doc/changes/changes_2.0.1.md diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 488b84c..e269a28 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,8 @@ on: jobs: matrix-build: runs-on: ubuntu-latest + permissions: + contents: read strategy: fail-fast: true matrix: @@ -39,13 +41,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: Publish Test Report - uses: scacap/action-surefire-report@v1 - if: always() - with: - report_paths: '**/target/surefire-reports/TEST-*.xml' - github_token: ${{ secrets.GITHUB_TOKEN }} - build: needs: matrix-build diff --git a/.github/workflows/github_release.sh b/.github/workflows/github_release.sh new file mode 100755 index 0000000..d26aab9 --- /dev/null +++ b/.github/workflows/github_release.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail + +base_dir="$( cd "$(dirname "$0")/../.." >/dev/null 2>&1 ; pwd -P )" +readonly base_dir +readonly pom_file="$base_dir/pom.xml" + +# Read project version from pom file +project_version=$(grep "" "$pom_file" | sed --regexp-extended 's/\s*(.*)<\/version>\s*/\1/g' | head --lines=1) +readonly project_version +echo "Read project version '$project_version' from $pom_file" + +# Create GitHub release +readonly changes_file="$base_dir/doc/changes/changes_${project_version}.md" +notes=$(cat "$changes_file") +readonly notes + +readonly title="Release $project_version" +readonly tag="$project_version" +echo "Creating release:" +echo "Git tag : $tag" +echo "Title : $title" +echo "Changes file : $changes_file" + +release_url=$(gh release create --latest --title "$title" --notes "$notes" --target main "$tag") +readonly release_url +echo "Release URL: $release_url" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ca2aa24 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,63 @@ +name: Release + +on: + workflow_dispatch: + inputs: + skip-deploy-maven-central: + description: "Skip deployment to Maven Central" + required: true + type: boolean + default: false + +jobs: + release: + runs-on: ubuntu-latest + defaults: + run: + shell: "bash" + concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + permissions: + contents: write # Required for creating GitHub release + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Fail if not running on main branch + if: ${{ github.ref != 'refs/heads/main' }} + uses: actions/github-script@v7 + with: + script: | + core.setFailed('Not running on main branch, github.ref is ${{ github.ref }}. Please start this workflow only on main') + + - name: Set up Maven Central Repository + uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: 11 + cache: "maven" + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} + gpg-passphrase: MAVEN_GPG_PASSPHRASE + + - name: Build + run: mvn --batch-mode -T 1C clean install + + - name: List secret GPG keys + run: gpg --list-secret-keys + + - name: Publish to Maven Central Repository + if: ${{ !inputs.skip-deploy-maven-central }} + run: mvn --batch-mode deploy -Possrh -DstagingDescription="Deployed via GitHub workflow release.yml" + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} + + - name: Create GitHub Release + run: ./.github/workflows/github_release.sh + env: + GH_TOKEN: ${{ github.token }} diff --git a/doc/changes/changes_2.0.1.md b/doc/changes/changes_2.0.1.md new file mode 100644 index 0000000..225bc8a --- /dev/null +++ b/doc/changes/changes_2.0.1.md @@ -0,0 +1,18 @@ +# hamcrest-multiline-text-matcher 2.0.1, released 2024-09-01 + +Codename: Update dependencies on top of 2.0.0 + +## Summary + +In version 2.0.1 we updated dependencies and plugins and updated to Hamcrest 3.0. + +## Changes + +* #6: Migrated deployment from JCentral to Maven Central +* #8: Updated dependencies +* #9: Updated dependencies + +## Bugfixes + +* #3: Fixed links in developer guide +* #7: Run Sonar only when token is available From 7e94459b91ad5e0b9a70f6580eb2ef14bf5c4749 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sun, 1 Sep 2024 16:47:43 +0200 Subject: [PATCH 09/15] Update changelog --- doc/changes/changelog.md | 4 ++- doc/changes/changes_2.0.1.md | 5 ++-- doc/changes/changes_2.0.2.md | 11 +++++++ doc/developer_guide/developer_guide.md | 41 ++++---------------------- 4 files changed, 22 insertions(+), 39 deletions(-) create mode 100644 doc/changes/changes_2.0.2.md diff --git a/doc/changes/changelog.md b/doc/changes/changelog.md index e111020..0aa0bf1 100644 --- a/doc/changes/changelog.md +++ b/doc/changes/changelog.md @@ -1,4 +1,6 @@ # Changes +* [2.0.2](changes_2.0.2.md) +* [2.0.1](changes_2.0.1.md) * [2.0.0](changes_2.0.0.md) -* [1.0.0](changes_1.0.0.md) \ No newline at end of file +* [1.0.0](changes_1.0.0.md) diff --git a/doc/changes/changes_2.0.1.md b/doc/changes/changes_2.0.1.md index 225bc8a..65e869b 100644 --- a/doc/changes/changes_2.0.1.md +++ b/doc/changes/changes_2.0.1.md @@ -1,16 +1,15 @@ -# hamcrest-multiline-text-matcher 2.0.1, released 2024-09-01 +# hamcrest-multiline-text-matcher 2.0.1, released 2021-04-17 Codename: Update dependencies on top of 2.0.0 ## Summary -In version 2.0.1 we updated dependencies and plugins and updated to Hamcrest 3.0. +In version 2.0.1 we updated dependencies. ## Changes * #6: Migrated deployment from JCentral to Maven Central * #8: Updated dependencies -* #9: Updated dependencies ## Bugfixes diff --git a/doc/changes/changes_2.0.2.md b/doc/changes/changes_2.0.2.md new file mode 100644 index 0000000..73738b8 --- /dev/null +++ b/doc/changes/changes_2.0.2.md @@ -0,0 +1,11 @@ +# hamcrest-multiline-text-matcher 2.0.2, released 2024-09-01 + +Codename: Update dependencies on top of 2.0.1 + +## Summary + +In version 2.0.1 we updated dependencies and plugins and updated to Hamcrest 3.0. We also added tests using Java 17 and 21. + +## Changes + +* #9: Updated dependencies diff --git a/doc/developer_guide/developer_guide.md b/doc/developer_guide/developer_guide.md index f4e4fa0..0fa967d 100644 --- a/doc/developer_guide/developer_guide.md +++ b/doc/developer_guide/developer_guide.md @@ -25,41 +25,12 @@ mvn versions:display-dependency-updates mvn versions:display-plugin-updates ``` -## Publishing to Maven Central - -1. Add the following to your `~/.m2/settings.xml`: - - ```xml - - - - ossrh - your-jira-id - your-jira-pwd - - - - - ossrh - - true - - - gpg - the_pass_phrase - - - - - ``` - -1. Checkout the `main` branch. -1. Update version in `pom.xml`, commit and push. -1. Run command - - ```bash - mvn -DskipSigningArtifacts=false clean deploy - ``` +## Creating a Release on Maven Central and GitHub +1. Start the release workflow + * Run command `gh workflow run release.yml --repo itsallcode/hamcrest-mutliline-text-matcher --ref main` + * or go to [GitHub Actions](https://github.com/itsallcode/hamcrest-mutliline-text-matcher/actions/workflows/release.yml) and start the `release.yml` workflow on branch `main`. +2. Update title and description of the newly created [GitHub release](https://github.com/itsallcode/hamcrest-mutliline-text-matcher/releases). +3. After some time the release will be available at [Maven Central](https://repo1.maven.org/maven2/org/itsallcode/hamcrest-mutliline-text-matcher/). 1. Create a [release](https://github.com/itsallcode/hamcrest-mutliline-text-matcher/releases) of the `main` branch on GitHub. 1. After some time the release will be available at [Maven Central](https://repo1.maven.org/maven2/org/itsallcode/hamcrest-mutliline-text-matcher/). From 0c585f9d77bb950824835c461a88647187a8f398 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sun, 1 Sep 2024 16:48:53 +0200 Subject: [PATCH 10/15] Specify permissions for codeql --- .github/workflows/codeql-analysis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2ab060c..3ec1e65 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -10,7 +10,9 @@ jobs: analyze: name: Analyze runs-on: ubuntu-latest - + permissions: + contents: read + security-events: write strategy: fail-fast: false From 27f1ff161fa6bffe2bd2f6e7045c6e7a94a74850 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sun, 1 Sep 2024 16:50:01 +0200 Subject: [PATCH 11/15] Delete eclipse config file --- .gitignore | 1 + .settings/org.eclipse.core.resources.prefs | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 .settings/org.eclipse.core.resources.prefs diff --git a/.gitignore b/.gitignore index 5402bb0..f5b34d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.settings/org.eclipse.jdt.apt.core.prefs /.settings/org.eclipse.m2e.core.prefs +/.settings/org.eclipse.core.resources.prefs /target/ /bin/ /.project diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index f9fe345..0000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/test/java=UTF-8 -encoding/=UTF-8 From 2d80a41622bf2c3206441263907847ab679c0485 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sun, 1 Sep 2024 16:50:22 +0200 Subject: [PATCH 12/15] Delete eclipse launch configurations --- ...ineTextMatcher - all tests coverage.launch | 25 ------------------- ...ltilineTextMatcher - license update.launch | 20 --------------- 2 files changed, 45 deletions(-) delete mode 100644 launch/MultilineTextMatcher - all tests coverage.launch delete mode 100644 launch/MultilineTextMatcher - license update.launch diff --git a/launch/MultilineTextMatcher - all tests coverage.launch b/launch/MultilineTextMatcher - all tests coverage.launch deleted file mode 100644 index 471b7a0..0000000 --- a/launch/MultilineTextMatcher - all tests coverage.launch +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/launch/MultilineTextMatcher - license update.launch b/launch/MultilineTextMatcher - license update.launch deleted file mode 100644 index 27b90a3..0000000 --- a/launch/MultilineTextMatcher - license update.launch +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - From a43d3ddc83be2d11b91e267c0d9a40fcedc628e1 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sun, 1 Sep 2024 16:56:37 +0200 Subject: [PATCH 13/15] Fix sonar findings --- .../java/org/itsallcode/matcher/MultilineTextMatcher.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/itsallcode/matcher/MultilineTextMatcher.java b/src/main/java/org/itsallcode/matcher/MultilineTextMatcher.java index f5e3f40..4bbb425 100644 --- a/src/main/java/org/itsallcode/matcher/MultilineTextMatcher.java +++ b/src/main/java/org/itsallcode/matcher/MultilineTextMatcher.java @@ -93,7 +93,7 @@ protected void describeMismatchSafely(final String text, final Description misma } } - private String describeLineCount(final int lineCount) + private static String describeLineCount(final int lineCount) { return "(" + lineCount + " lines)" + LINE_SEPARATOR; } @@ -119,12 +119,13 @@ public void describeTo(final Description description) * @param lines the expected lines * @return the matcher */ + @SuppressWarnings("java:S923") // Varargs are required here public static MultilineTextMatcher matchesAllLines(final String... lines) { return new MultilineTextMatcher(String.join(LINE_SEPARATOR, lines)); } - private List splitPreservingNewLines(final String text) + private static List splitPreservingNewLines(final String text) { final String lineSplittingRegEx = "(?<=" + LINE_ENDING + ")"; final List lines = new ArrayList<>(); @@ -135,4 +136,4 @@ private List splitPreservingNewLines(final String text) } return lines; } -} \ No newline at end of file +} From 368256d287d26a20170e10f055ae10f6089f0bd2 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Sun, 1 Sep 2024 16:59:52 +0200 Subject: [PATCH 14/15] Fix merge conflict --- pom.xml | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/pom.xml b/pom.xml index dc0ebb9..a1c70aa 100644 --- a/pom.xml +++ b/pom.xml @@ -70,25 +70,6 @@ - - org.apache.maven.plugins - maven-toolchains-plugin - 3.1.0 - - - - toolchain - - - - - - - ${java.version} - - - - org.apache.maven.plugins maven-compiler-plugin From c2fa2eb35af77356d5fa5362701cbb03f90a6a68 Mon Sep 17 00:00:00 2001 From: kaklakariada Date: Mon, 2 Sep 2024 06:48:09 +0200 Subject: [PATCH 15/15] Update release date --- doc/changes/changes_2.0.2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changes/changes_2.0.2.md b/doc/changes/changes_2.0.2.md index 73738b8..abe4c7d 100644 --- a/doc/changes/changes_2.0.2.md +++ b/doc/changes/changes_2.0.2.md @@ -1,4 +1,4 @@ -# hamcrest-multiline-text-matcher 2.0.2, released 2024-09-01 +# hamcrest-multiline-text-matcher 2.0.2, released 2024-09-02 Codename: Update dependencies on top of 2.0.1