From 6b5abf65c4b079c740cf85f35d4f3e74fa45140f Mon Sep 17 00:00:00 2001 From: Julien Loizelet Date: Tue, 8 Aug 2023 10:12:52 +0900 Subject: [PATCH] feat(*): Prepare release v1.0.0 (#13) * style(commit): Add conventional commit git hook template * docs(changelog): Add changelog * ci(release): Add release GitHub action * docs(readme): Change maintainer mentions * docs(*): Prepare release v1.0.0 --- .githooks/commit-msg | 22 ++++++++ .github/workflows/release.yml | 99 +++++++++++++++++++++++++++++++++++ CHANGELOG.md | 99 +++++++++++++++++++++++++++++++++++ README.md | 13 ++++- 4 files changed, 231 insertions(+), 2 deletions(-) create mode 100644 .githooks/commit-msg create mode 100644 .github/workflows/release.yml create mode 100644 CHANGELOG.md diff --git a/.githooks/commit-msg b/.githooks/commit-msg new file mode 100644 index 0000000..1608390 --- /dev/null +++ b/.githooks/commit-msg @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +if [ -z "$1" ]; then + echo "Missing argument (commit message). Did you try to run this manually?" + exit 1 +fi + +commitTitle="$(cat $1 | head -n1)" + +# ignore merge +if echo "$commitTitle" | grep -qE "^Merge"; then + echo "Commit hook: ignoring merge" + exit 0 +fi + +# check commit message +REGEX='^(feat|fix|docs|style|refactor|ci|test|chore|comment)\(.*\)\:.*' +if ! echo "$commitTitle" | grep -qE ${REGEX}; then + echo "Your commit title '$commitTitle' did not follow conventional commit message rules:" + echo "Please comply with the regex ${REGEX}" + exit 1 +fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f8ce518 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,99 @@ +name: Create Release +# example: gh workflow run release.yml -f tag_name=v1.1.4 -f draft=true +on: + workflow_dispatch: + branches: + - main + inputs: + tag_name: + type: string + required: true + draft: + type: boolean + description: Draft release + default: false + prerelease: + type: boolean + description: Prerelease + default: false + +jobs: + create-release: + name: Create release + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Check naming convention + run: | + VERIF=$(echo ${{ github.event.inputs.tag_name }} | grep -E "^v([0-9]{1,}\.)([0-9]{1,}\.)([0-9]{1,})(-(alpha|beta)\.[0-9]{1,})?$") + if [ ! ${VERIF} ] + then + echo "Tag name '${{ github.event.inputs.tag_name }}' does not comply with naming convention vX.Y.Z" + exit 1 + fi + + - name: Set version number with v + run: | + echo "VERSION_NUMBER=$(echo ${{ github.event.inputs.tag_name }})" >> $GITHUB_ENV + + - name: Clone sources + uses: actions/checkout@v3 + + - name: Check version ${{ env.VERSION_NUMBER }} consistency in files + # Check CHANGELOG.md + run: | + + # Check top ## [VERSION_NUMBER](GITHUB_URL/releases/tag/VERSION_NUMBER) - yyyy-mm-dd in CHANGELOG.md + CURRENT_DATE=$(date +'%Y-%m-%d') + echo $CURRENT_DATE + CHANGELOG_VERSION=$(grep -o -E "## \[(.*)\].* - $CURRENT_DATE" CHANGELOG.md | head -1 | sed 's/ //g') + echo $CHANGELOG_VERSION + if [[ $CHANGELOG_VERSION == "##[${{ env.VERSION_NUMBER }}]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/${{ env.VERSION_NUMBER }})-$CURRENT_DATE" ]] + then + echo "CHANGELOG VERSION OK" + else + echo "CHANGELOG VERSION KO" + exit 1 + fi + + # Check top [_Compare with previous release_](GITHUB_URL/compare/LAST_TAG...VERSION_NUMBER) in CHANGELOG.md + COMPARISON=$(grep -oP "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/compare/\K(.*)$" CHANGELOG.md | head -1) + LAST_TAG=$(curl -Ls -o /dev/null -w %{url_effective} $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/latest | grep -oP "\/tag\/\K(.*)$") + if [[ $COMPARISON == "$LAST_TAG...${{ env.VERSION_NUMBER }})" ]] + then + echo "VERSION COMPARISON OK" + else + echo "VERSION COMPARISON KO" + echo $COMPARISON + echo "$LAST_TAG...${{ env.VERSION_NUMBER }})" + exit 1 + fi + + - name: Create Tag ${{ github.event.inputs.tag_name }} + uses: actions/github-script@v6 + with: + github-token: ${{ github.token }} + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: "refs/tags/${{ github.event.inputs.tag_name }}", + sha: context.sha + }) + + - name: Prepare release notes + run: | + # Retrieve release body from CHANGELOG.md and remove --- + VERSION_RELEASE_NOTES=$(awk -v ver="[${{ env.VERSION_NUMBER }}]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/${{ env.VERSION_NUMBER }})" '/^## / { if (p) { exit }; if ($2 == ver) { p=1; next} } p && NF' CHANGELOG.md | sed ':a;N;$!ba;s/\n---/ /g') + echo "$VERSION_RELEASE_NOTES" >> CHANGELOG.txt + + - name: Create release ${{ env.VERSION_NUMBER }} + uses: softprops/action-gh-release@v1 + with: + body_path: CHANGELOG.txt + name: ${{ env.VERSION_NUMBER }} + tag_name: ${{ github.event.inputs.tag_name }} + draft: ${{ github.event.inputs.draft }} + prerelease: ${{ github.event.inputs.prerelease }} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d9c1bc8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,99 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## SemVer public API + +The [public API](https://semver.org/spec/v2.0.0.html#spec-item-1) of this project is defined by the `install.yaml` file and `project_files` listed in the `install.yaml` file. + +--- + + +## [v1.0.0](https://github.com/ddev/ddev-mongo/releases/tag/v1.0.0) - 2023-08-08 +[_Compare with previous release_](https://github.com/ddev/ddev-mongo/compare/v0.1.4...v1.0.0) + +### Added + +- Add `ddev mongosh` command + +--- + + +## [v0.1.4](https://github.com/ddev/ddev-mongo/releases/tag/v0.1.4) - 2023-02-04 +[_Compare with previous release_](https://github.com/ddev/ddev-mongo/compare/v0.1.3...v0.1.4) + +### Changed + +- Move to ddev domain + +--- + +## [v0.1.3](https://github.com/ddev/ddev-mongo/releases/tag/v0.1.3) - 2022-12-10 +[_Compare with previous release_](https://github.com/ddev/ddev-mongo/compare/v0.1.2...v0.1.3) + +### Fixed + +- Add ddev-description in `install.yaml` + +--- + +## [v0.1.2](https://github.com/ddev/ddev-mongo/releases/tag/v0.1.2) - 2022-06-22 +[_Compare with previous release_](https://github.com/ddev/ddev-mongo/compare/v0.1.1...v0.1.2) + +### Fixed + +- Make test failures more readable + +--- + + +## [v0.1.1](https://github.com/ddev/ddev-mongo/releases/tag/v0.1.1) - 2022-06-22 +[_Compare with previous release_](https://github.com/ddev/ddev-mongo/compare/v0.1.0...v0.1.1) + +### Fixed + +- Add missing ddev-generated comment + +--- + + +## [v0.1.0](https://github.com/ddev/ddev-mongo/releases/tag/v0.1.0) - 2022-04-05 +[_Compare with previous release_](https://github.com/ddev/ddev-mongo/compare/v0.0.3...v0.1.0) + +### Changed + +- Increase healthcheck timeout to 60s + +--- + + +## [v0.0.3](https://github.com/ddev/ddev-mongo/releases/tag/v0.0.3) - 2022-03-30 +[_Compare with previous release_](https://github.com/ddev/ddev-mongo/compare/v0.0.2...v0.0.3) + +### Changed + +- Make mongo-express dependent on mongo +- Change host-side port to 9091 for fewer conflicts + +### Fixed + +- Fix healthcheck + +--- + +## [v0.0.2](https://github.com/ddev/ddev-mongo/releases/tag/v0.0.2) - 2022-03-29 +[_Compare with previous release_](https://github.com/ddev/ddev-mongo/compare/v0.0.1...v0.0.2) + +### Added + +- Add healthcheck + +--- + +## [0.0.1](https://github.com/ddev/ddev-mongo/releases/tag/v0.0.1) - 2022-03-29 + +### Added +- Initial release diff --git a/README.md b/README.md index bb4d1c6..581467c 100644 --- a/README.md +++ b/README.md @@ -20,14 +20,23 @@ It's based on [MongoDb from Docker Hub](https://hub.docker.com/_/mongo?tab=descr Mongo Express will now be accessible from `http://.ddev.site:9091` + +## Features + +### `ddev mongosh` command + +This command will run the `mongosh` (mongoDB Shell) command in the `mongo` container. Please [read the documentation](https://www.mongodb.com/docs/mongodb-shell/) for more information. + + ## Caveats: * The php extension (phpX.X-mongodb) is set up in `.ddev/config.mongo.yaml` using `webimage_extra_packages`. If you have an earlier `webimage_extra_packages` in your config.yaml, this will override it. You may want to edit your config.yaml to do what you want and remove the config.mongo.yaml. * You can't define custom MongoDB configuration with this current setup. * You can't use `ddev import-db` to import to mongo. -**Contributed and maintained by [@rfay](https://github.com/rfay), but looking for co-maintainers who use mongo regularly and know something about it.** **Based on the original [ddev-contrib recipe](https://github.com/ddev/ddev-contrib/tree/master/docker-compose-services/mongodb)** -**Originally ontributed by [@wtfred](https://github.com/wtfred)** +**Originally contributed by [@wtfred](https://github.com/wtfred)** + +**Maintained by [@julienloizelet](https://github.com/julienloizelet)**