diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..154386f --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,51 @@ +# Copyright © 2023 OpenIM. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name-template: 'v$RESOLVED_VERSION 🌈' +tag-template: 'v$RESOLVED_VERSION' +categories: + - title: '🚀 Features' + labels: + - 'feature' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'kind/fix' + - 'kind/feature' + - 'enhancement' + - 'kind/documentation' + - 'good first issue' + - title: '🧰 Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: patch +template: | + ## Changes $PREVIOUS_TAG + + $CHANGES + + ## Contributors to this $REPOSITORY release + + $CONTRIBUTORS \ No newline at end of file diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml new file mode 100644 index 0000000..d8cbf0b --- /dev/null +++ b/.github/workflows/build-docker-image.yml @@ -0,0 +1,251 @@ +# Copyright © 2023 OpenIM open source community. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Publish OpenKF Docker image + +on: + push: + branches: + - main + - release-* + tags: + - v* + workflow_dispatch: + +env: + # Common versions + GO_VERSION: "1.20" + +jobs: + build-server-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + +# docker.io/openim/openim-server:latest + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.6.0 + with: + images: openim/openkf-server + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./deploy/docker/Dockerfile.server + # linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + build-server-aliyun: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 +# registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:latest + - name: Extract metadata (tags, labels) for Docker + id: meta2 + uses: docker/metadata-action@v4.6.0 + with: + images: registry.cn-hangzhou.aliyuncs.com/openimsdk/openkf-server + + - name: Log in to AliYun Docker Hub + uses: docker/login-action@v2 + with: + registry: registry.cn-hangzhou.aliyuncs.com + username: ${{ secrets.ALIREGISTRY_USERNAME }} + password: ${{ secrets.ALIREGISTRY_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./deploy/docker/Dockerfile.server + # linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} + + build-server-ghcr: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 +# ghcr.io/openimsdk/openim-server:latest + - name: Extract metadata (tags, labels) for Docker + id: meta3 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openkf-server + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./deploy/docker/Dockerfile.server + # linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta3.outputs.tags }} + labels: ${{ steps.meta3.outputs.labels }} + + build-web-dockerhub: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + +# docker.io/openim/openim-web:latest + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.6.0 + with: + images: openim/openkf-web + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./deploy/docker/Dockerfile.web + # linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + build-web-aliyun: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 +# registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-web:latest + - name: Extract metadata (tags, labels) for Docker + id: meta2 + uses: docker/metadata-action@v4.6.0 + with: + images: registry.cn-hangzhou.aliyuncs.com/openimsdk/openkf-web + + - name: Log in to AliYun Docker Hub + uses: docker/login-action@v2 + with: + registry: registry.cn-hangzhou.aliyuncs.com + username: ${{ secrets.ALIREGISTRY_USERNAME }} + password: ${{ secrets.ALIREGISTRY_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./deploy/docker/Dockerfile.web + # linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} + + build-web-ghcr: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 +# ghcr.io/openimsdk/openim-web:latest + - name: Extract metadata (tags, labels) for Docker + id: meta3 + uses: docker/metadata-action@v4.6.0 + with: + images: ghcr.io/openimsdk/openkf-web + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./deploy/docker/Dockerfile.web + # linux/ppc64le,linux/s390x + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta3.outputs.tags }} + labels: ${{ steps.meta3.outputs.labels }} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..0eed809 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,55 @@ +# Copyright © 2023 OpenIM. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - main + # pull_request event is required only for autolabeler + pull_request: + # Only following types are handled by the action, but one can default to all as well + # types: [opened, reopened, synchronize] + # pull_request_target event is required for autolabeler to support PRs from forks + # pull_request_target: + # types: [opened, reopened, synchronize] + +permissions: + contents: read + +jobs: + update_release_draft: + permissions: + # write permission is required to create a github release + contents: write + # write permission is required for autolabeler + # otherwise, read permission is required at least + pull-requests: write + runs-on: ubuntu-latest + steps: + # (Optional) GitHub Enterprise requires GHE_HOST variable set + #- name: Set GHE_HOST + # run: | + # echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV + + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml + # with: + # config-name: my-config.yml + # disable-autolabeler: true + env: + GITHUB_TOKEN: ${{ secrets.REDBOT_GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c833b23..3978a2e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,33 +1,81 @@ -name: goreleaser +# Copyright © 2023 OpenIM. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: OpenKF Server Release Workflow on: push: + # run only against tags tags: - '*' + permissions: contents: write + packages: write + issues: write jobs: goreleaser: runs-on: ubuntu-latest steps: - - - name: Checkout - uses: actions/checkout@v3 + - uses: actions/checkout@v3 with: fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v4 - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 + - run: git fetch --force --tags + - uses: actions/setup-go@v4 + with: + go-version: stable + # More assembly might be required: Docker logins, GPG, etc. It all depends + # on your needs. + - uses: goreleaser/goreleaser-action@v4 with: - # either 'goreleaser' (default) or 'goreleaser-pro' + # either 'goreleaser' (default) or 'goreleaser-pro': distribution: goreleaser version: latest - args: release --clean + workdir: . + args: release -f ./build/goreleaser.yaml --rm-dist --clean --release-footer-tmpl=scripts/template/footer.md.tmpl --release-header-tmpl=scripts/template/head.md.tmpl env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution + USERNAME: ${{ github.repository_owner }} + GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} + FURY_TOKEN: ${{ secrets.FURY_TOKEN }} + # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' + # distribution: # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} + + goreleaser-check-pkgs: + runs-on: ubuntu-latest + env: + DOCKER_CLI_EXPERIMENTAL: "enabled" + needs: [ goreleaser ] + if: github.ref == 'refs/heads/main' + strategy: + matrix: + format: [ deb, rpm, apk ] + steps: + - uses: actions/checkout@v3 # v3 + with: + fetch-depth: 0 + - uses: arduino/setup-task@e26d8975574116b0097a1161e0fe16ba75d84c1c # v1 + with: + version: 3.x + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # v2 + - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 + with: + path: | + ./_output/dist/*.deb + ./_output/dist/*.rpm + ./_output/dist/*.apk + key: ${{ github.ref }} + - run: task goreleaser:test:${{ matrix.format }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 8eece81..0000000 --- a/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright © 2023 OpenIMSDK open source community. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM golang:alpine as builder \ No newline at end of file diff --git a/Makefile b/Makefile index 658c581..85eab0e 100644 --- a/Makefile +++ b/Makefile @@ -102,8 +102,8 @@ XARGS := xargs -r # ============================================================================== # TODO: License selection -# LICENSE_TEMPLATE ?= $(ROOT_DIR)/scripts/LICENSE/license_templates.txt # MIT License -LICENSE_TEMPLATE ?= $(ROOT_DIR)/scripts/LICENSE/LICENSE_TEMPLATES # Apache License +# LICENSE_TEMPLATE ?= $(ROOT_DIR)/scripts/template/license_templates.txt # MIT License +LICENSE_TEMPLATE ?= $(ROOT_DIR)/scripts/template/LICENSE_TEMPLATES # Apache License # COMMA: Concatenate multiple strings to form a list of strings COMMA := , @@ -115,7 +115,7 @@ SPACE += # ============================================================================== # Build definition -GO_SUPPORTED_VERSIONS ?= 1.18|1.19|1.20 +GO_SUPPORTED_VERSIONS ?= 1.18|1.19|1.20|1.21 GO_LDFLAGS += -X $(VERSION_PACKAGE).GitVersion=$(VERSION) \ -X $(VERSION_PACKAGE).GitCommit=$(GIT_COMMIT) \ -X $(VERSION_PACKAGE).GitTreeState=$(GIT_TREE_STATE) \ @@ -251,6 +251,12 @@ vet: generate: @cd $(SERVER_DIR) && $(GO) generate ./... +## githook: Copy githook scripts when execute makefile +.PHONY: githook +githook: + @echo "===========> Copy githook scripts when execute makefile" + @./scripts/init-githooks.sh + ## lint: Run go lint against code. # go1.19+ .PHONY: lint diff --git a/.goreleaser.yaml b/build/goreleaser.yaml similarity index 62% rename from .goreleaser.yaml rename to build/goreleaser.yaml index fd1b13f..d6f0660 100644 --- a/.goreleaser.yaml +++ b/build/goreleaser.yaml @@ -1,11 +1,22 @@ # .goreleaser.yaml +before: + hooks: + # You may remove this if you don't use go modules. + - make tidy + - make copyright.add + +snapshot: + name_template: "{{ incpatch .Version }}-next" + +report_sizes: true + builds: # You can have multiple builds defined as a yaml list - # # ID of the build. # # Default: Binary name - id: "my-build" + id: "openkf-server" # Path to main.go file or main package. # Notice: when used with `gomod.proxy`, this must be a package. @@ -243,3 +254,152 @@ builds: - foobaz env: - CGO_ENABLED=1 + +# TODO:Need a script, such as the init - release to help binary to find the right directory +# ,which can be compiled binary +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of uname. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + + # Set this to true if you want all files in the archive to be in a single directory. + # If set to true and you extract the archive 'goreleaser_Linux_arm64.tar.gz', + # you'll get a folder 'goreleaser_Linux_arm64'. + # If set to false, all files are extracted separately. + # You can also set it to a custom folder name (templating is supported). + wrap_in_directory: true + + # use zip for windows archives + files: + - CHANGELOG/* + - deployment/* + - server/config.yaml + - build/* + - scripts/* + - Makefile + - docs/* + - src: "*.md" + dst: docs + + # Strip parent folders when adding files to the archive. + strip_parent: true + + # File info. + # Not all fields are supported by all formats available formats. + # + # Default: copied from the source file + info: + # Templates: allowed (since v1.14) + owner: root + + # Templates: allowed (since v1.14) + group: root + + # Must be in time.RFC3339Nano format. + # + # Templates: allowed (since v1.14) + mtime: "{{ .CommitDate }}" + + # File mode. + mode: 0644 + + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + use: github + filters: + exclude: + - "^test:" + - "^chore" + - "merge conflict" + - Merge pull request + - Merge remote-tracking branch + - Merge branch + - go mod tidy + groups: + - title: Dependency updates + regexp: '^.*?(feat|fix)\(deps\)!?:.+$' + order: 300 + - title: "New Features" + regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$' + order: 100 + - title: "Security updates" + regexp: '^.*?sec(\([[:word:]]+\))??!?:.+$' + order: 150 + - title: "Bug fixes" + regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$' + order: 200 + - title: "Documentation updates" + regexp: ^.*?doc(\([[:word:]]+\))??!?:.+$ + order: 400 + - title: "Build process updates" + regexp: ^.*?build(\([[:word:]]+\))??!?:.+$ + order: 400 + - title: Other work + order: 9999 + + +nfpms: + - id: packages + builds: + - openkf-server + # Your app's vendor. + vendor: OpenIMSDK + homepage: https://github.com/OpenIMSDK/Open-IM-Server + maintainer: kubbot + description: |- + Auto sync github labels + kubbot && openimbot + license: MIT + formats: + - apk + - deb + - rpm + - termux.deb # Since: v1.11 + - archlinux # Since: v1.13 + dependencies: + - git + recommends: + - golang + +# Default: './dist' +dist: ./_output/dist + + +# .goreleaser.yaml +milestones: + # You can have multiple milestone configs + - + # Repository for the milestone + # Default is extracted from the origin remote URL + repo: + owner: OpenIMSDK + name: OpenKF + + # Whether to close the milestone + close: true + + # Fail release on errors, such as missing milestone. + fail_on_error: false + + # Name of the milestone + # + # Default: '{{ .Tag }}' + name_template: "Current Release" + + +checksum: + name_template: "{{ .ProjectName }}_checksums.txt" + algorithm: sha256 + +release: + prerelease: auto \ No newline at end of file diff --git a/deploy/docker/Dockerfile.web b/deploy/docker/Dockerfile.web index 0f430a8..137c935 100644 --- a/deploy/docker/Dockerfile.web +++ b/deploy/docker/Dockerfile.web @@ -18,7 +18,8 @@ FROM node:18 AS builder WORKDIR /openkf-web COPY /web . -RUN npm install \ +RUN npm set registry http://registry.npm.taobao.org/ \ + && npm install --registry=http://registry.npm.taobao.org \ && chmod +x scripts/setup.sh && ./scripts/setup.sh \ && npm run build diff --git a/scripts/githooks/commit-msg b/scripts/githooks/commit-msg.sh similarity index 100% rename from scripts/githooks/commit-msg rename to scripts/githooks/commit-msg.sh diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit.sh similarity index 100% rename from scripts/githooks/pre-commit rename to scripts/githooks/pre-commit.sh diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push.sh similarity index 100% rename from scripts/githooks/pre-push rename to scripts/githooks/pre-push.sh diff --git a/scripts/init-githooks.sh b/scripts/init-githooks.sh new file mode 100755 index 0000000..399054b --- /dev/null +++ b/scripts/init-githooks.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +# Copyright © 2023 OpenIM. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ----------------------------------------------------------------------------- +# init-githooks.sh +# +# This script assists in managing Git hooks for the OpenIM project. +# When executed: +# 1. It prompts the user to enable git hooks. +# 2. If the user accepts, it copies predefined hook scripts to the appropriate +# Git directory, making them executable. +# 3. If requested, it can delete the added hooks. +# +# This script equal runs `make init-githooks` command. +# Usage: +# ./init-githooks.sh Prompt to enable git hooks. +# ./init-githooks.sh --delete Delete previously added git hooks. +# ./init-githooks.sh --help Show the help message. +# +# Example: `scripts/build-go.sh --help`. +# Documentation & related context can be found at: +# https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694 +# +# ----------------------------------------------------------------------------- + +OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +HOOKS_DIR="${OPENIM_ROOT}/.git/hooks" + +help_info() { + echo "Usage: $0 [options]" + echo + echo "This script helps to manage git hooks." + echo + echo "Options:" + echo " -h, --help Show this help message and exit." + echo " -d, --delete Delete the hooks that have been added." + echo " By default, it will prompt to enable git hooks." +} + +delete_hooks() { + for file in ${OPENIM_ROOT}/scripts/githooks/*.sh; do + hook_name=$(basename "$file" .sh) # This removes the .sh extension + rm -f "$HOOKS_DIR/$hook_name" + done + echo "Git hooks have been deleted." +} + +enable_hooks() { + echo "Would you like to:" + echo "1) Enable git hooks mode" + echo "2) Delete existing git hooks" + echo "Please select a number (or any other key to exit):" + read -r choice + + case "$choice" in + 1) + for file in ${OPENIM_ROOT}/scripts/githooks/*.sh; do + hook_name=$(basename "$file" .sh) # This removes the .sh extension + cp -f "$file" "$HOOKS_DIR/$hook_name" + done + + chmod +x $HOOKS_DIR/* + + echo "Git hooks mode has been enabled." + echo "With git hooks enabled, every time you perform a git action (e.g. git commit), the corresponding hooks script will be triggered automatically." + echo "This means that if the size of the file you're committing exceeds the set limit (e.g. 42MB), the commit will be rejected." + ;; + 2) + delete_hooks + ;; + *) + echo "Exiting without making changes." + ;; + esac +} + + +case "$1" in + -h|--help) + help_info + ;; + -d|--delete) + delete_hooks + ;; + *) + enable_hooks + ;; +esac diff --git a/scripts/LICENSE/LICENSE.md b/scripts/template/LICENSE similarity index 99% rename from scripts/LICENSE/LICENSE.md rename to scripts/template/LICENSE index f49a4e1..261eeb9 100644 --- a/scripts/LICENSE/LICENSE.md +++ b/scripts/template/LICENSE @@ -198,4 +198,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file + limitations under the License. diff --git a/scripts/LICENSE/LICENSE_TEMPLATES b/scripts/template/LICENSE_TEMPLATES similarity index 100% rename from scripts/LICENSE/LICENSE_TEMPLATES rename to scripts/template/LICENSE_TEMPLATES diff --git a/scripts/template/boilerplate.txt b/scripts/template/boilerplate.txt new file mode 100644 index 0000000..2f12334 --- /dev/null +++ b/scripts/template/boilerplate.txt @@ -0,0 +1,3 @@ +Copyright © {{.Year}} {{.Holder}} All rights reserved. +Use of this source code is governed by a MIT style +license that can be found in the LICENSE file. diff --git a/scripts/template/footer.md.tmpl b/scripts/template/footer.md.tmpl new file mode 100644 index 0000000..b201c45 --- /dev/null +++ b/scripts/template/footer.md.tmpl @@ -0,0 +1,19 @@ +**Full Changelog**: https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/compare/{{ .PreviousTag }}...{{ .Tag }} + +## Get Involved with OpenKF! + +Your patronage towards OpenKF is greatly appreciated 🎉🎉. + +If you encounter any problems during its usage, please create an issue in the [GitHub repository](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/), we're committed to resolving your problem as soon as possible. + +**Here are some ways to get involved with the OpenKF community:** + +📢 **Slack Channel**: Join our Slack channels for discussions, communication, and support. Click [here](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q) to join the Open-IM-Server Slack team channel. + +📧 **Gmail Contact**: If you have any questions, suggestions, or feedback for our open-source projects, please feel free to [contact us via email](https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=winxu81@gmail.com). + +📖 **Blog**: Stay up-to-date with OpenKF projects and trends by reading our [blog](https://openkf.top/). We share the latest developments, tech trends, and other interesting information related to OpenKF. + +📱 **WeChat**: Add us on WeChat (QR Code) and indicate that you are a user or developer of Open-IM-Server. We'll process your request as soon as possible. + +Remember, your contributions play a vital role in making OpenKF successful, and we look forward to your active participation in our community! 🙌 \ No newline at end of file diff --git a/scripts/template/head.md.tmpl b/scripts/template/head.md.tmpl new file mode 100644 index 0000000..cc5f38b --- /dev/null +++ b/scripts/template/head.md.tmpl @@ -0,0 +1,31 @@ +## Welcome to the {{ .Tag }} release of [OpenKF](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }})!🎉🎉! + +We are excited to release {{.Tag}}, Branch: https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/tree/{{ .Tag }} , Git hash [{{ .ShortCommit }}], Install Address: [{{ .ReleaseURL }}]({{ .ReleaseURL }}) + +Learn more about versions of OpenKF: + ++ We release logs are recorded on [✨CHANGELOG](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/blob/main/CHANGELOG/CHANGELOG.md) + ++ For information on versions of OpenKF and how to maintain branches, read [📚this article](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/blob/main/docs/conversions/version.md) + ++ If you wish to use mirroring, read OpenKF's [🤲image management policy](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/blob/main/docs/conversions/images.md) + +**Want to be one of them 😘?** + +

+ + + + + + + + + +

+ +> **Note** +> @openimbot and @kubbot have made great contributions to the community as community 🤖robots(@openimsdk/bot), respectively. +> Thanks to the @openimsdk/openim team for all their hard work on this release. +> Thank you to all the [💕developers and contributors](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/graphs/contributors), people from all over the world, OpenKF brings us together +> Contributions to this project are welcome! Please see [CONTRIBUTING.md](https://github.com/{{ .Env.USERNAME }}/{{ .ProjectName }}/blob/main/CONTRIBUTING.md) for details. \ No newline at end of file diff --git a/scripts/template/project_README.md b/scripts/template/project_README.md new file mode 100644 index 0000000..96575e6 --- /dev/null +++ b/scripts/template/project_README.md @@ -0,0 +1,41 @@ +# Project myproject + + + +## Features + + + +## Getting Started + +### Prerequisites + + + +### Building + + + +### Running + + + +## Using + + + +## Contributing + + + +## Community(optional) + + + +## Authors + + + +## License + + diff --git a/server/go.mod b/server/go.mod index e84c7a8..a0402a0 100644 --- a/server/go.mod +++ b/server/go.mod @@ -17,6 +17,7 @@ require ( github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5 github.com/shomali11/slacker v1.4.1 github.com/sirupsen/logrus v1.9.3 + github.com/slack-go/slack v0.12.1 github.com/spf13/viper v1.16.0 github.com/swaggo/files v1.0.1 github.com/swaggo/gin-swagger v1.6.0 @@ -78,7 +79,6 @@ require ( github.com/rs/xid v1.5.0 // indirect github.com/shomali11/commander v0.0.0-20220716022157-b5248c76541a // indirect github.com/shomali11/proper v0.0.0-20180607004733-233a9a872c30 // indirect - github.com/slack-go/slack v0.12.1 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect