From 8d95df2c119abceac0605256eff5db936b9ae77e Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong (cubxxw)" <3293172751nss@gmail.com>
Date: Thu, 21 Mar 2024 18:38:48 +0800
Subject: [PATCH] feat: set type check
---
.github/workflows/auto-assign-issue.yml | 30 ++++
.github/workflows/cla.yml | 52 ++++++
.github/workflows/release.yml | 65 +++++++
.goreleaser.yaml | 222 ++++++++++++++++++++++++
4 files changed, 369 insertions(+)
create mode 100644 .github/workflows/auto-assign-issue.yml
create mode 100644 .github/workflows/cla.yml
create mode 100644 .github/workflows/release.yml
create mode 100644 .goreleaser.yaml
diff --git a/.github/workflows/auto-assign-issue.yml b/.github/workflows/auto-assign-issue.yml
new file mode 100644
index 0000000..3bb16c5
--- /dev/null
+++ b/.github/workflows/auto-assign-issue.yml
@@ -0,0 +1,30 @@
+# Copyright © 2024 KubeCub open source community. All rights reserved.
+# Licensed under the MIT License (the "License");
+# you may not use this file except in compliance with the License.
+
+name: Assign issue to comment author
+on:
+ issue_comment:
+ types: [created]
+jobs:
+ assign-issue:
+ if: contains(github.event.comment.body, '/assign') || contains(github.event.comment.body, '/accept')
+ runs-on: ubuntu-latest
+ permissions:
+ issues: write
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+
+ - name: Assign the issue
+ run: |
+ export LETASE_MILESTONES=$(curl "https://api.github.com/repos/$OWNER/$REPO/milestones" | jq -r 'last(.[]).title')
+ gh issue edit ${{ github.event.issue.number }} --add-assignee "${{ github.event.comment.user.login }}"
+ gh issue edit ${{ github.event.issue.number }} --add-label "triage/accepted"
+ gh issue edit ${{ github.event.issue.number }} --milestone "$LETASE_MILESTONES"
+ gh issue comment $ISSUE --body "@${{ github.event.comment.user.login }} Glad to see you accepted this issue🤲, this issue has been assigned to you.
I set the milestones for this issue to $LETASE_MILESTONES, we are looking forward to your PR!"
+ env:
+ GH_TOKEN: ${{ secrets.REDBOT_GITHUB_TOKEN }}
+ ISSUE: ${{ github.event.issue.html_url }}
+ OWNER: ${{ github.repository_owner }}
+ REPO: ${{ github.event.repository.name }}
\ No newline at end of file
diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml
new file mode 100644
index 0000000..f54531f
--- /dev/null
+++ b/.github/workflows/cla.yml
@@ -0,0 +1,52 @@
+# Copyright © 2024 KubeCub open source community. All rights reserved.
+# Licensed under the MIT License (the "License");
+# you may not use this file except in compliance with the License.
+
+name: "OpenIM CLA Assistant"
+on:
+ issue_comment:
+ types: [created]
+ pull_request_target:
+ types: [opened,closed,synchronize]
+
+# explicitly configure permissions, in case your GITHUB_TOKEN workflow permissions are set to read-only in repository settings
+permissions:
+ actions: write
+ contents: write
+ pull-requests: write
+ statuses: write
+
+env:
+ # Define Open-IM-Server variables here
+ OPEN_IM_SERVER_REMOTE_ORGANIZATION: openim-sigs
+ REMOTE_REPOSITORY: cla
+ OPEN_IM_SERVER_CLA_DOCUMENT: https://github.com/openim-sigs/cla/blob/main/README.md
+ OPEN_IM_SERVER_SIGNATURES_PATH: signatures/${{ github.event.repository.name }}/cla.json
+
+ OPEN_IM_SERVER_ALLOWLIST: kubbot,bot*
+
+jobs:
+ CLAAssistant:
+ runs-on: ubuntu-latest
+ steps:
+ - name: "CLA Assistant"
+ if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
+ uses: contributor-assistant/github-action@v2.3.0
+ env:
+ GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
+ PERSONAL_ACCESS_TOKEN: ${{ secrets.REDBOT_GITHUB_TOKEN }}
+ with:
+ path-to-signatures: ${{ env.OPEN_IM_SERVER_SIGNATURES_PATH }}
+ path-to-document: ${{ env.OPEN_IM_SERVER_CLA_DOCUMENT }}
+ branch: 'main'
+ allowlist: ${{ env.OPEN_IM_SERVER_ALLOWLIST }}
+
+ remote-organization-name: ${{ env.OPEN_IM_SERVER_REMOTE_ORGANIZATION }}
+ remote-repository-name: ${{ env.REMOTE_REPOSITORY }}
+
+ create-file-commit-message: '📚 Docs: Creating file for storing ${{ github.event.repository.name }} CLA Signatures'
+ custom-notsigned-prcomment: '💕 Thank you for your contribution and please kindly read and sign our [🎯https://github.com/openim-sigs/cla/blob/main/README.md](https://github.com/openim-sigs/cla/blob/main/README.md)'
+ custom-pr-sign-comment: 'I have read the CLA Document and I hereby sign the CLA'
+ custom-allsigned-prcomment: '🤖 All Contributors have signed the [${{ github.event.repository.name }} CLA](https://github.com/openim-sigs/cla/blob/main/README.md).\n 🤖 The signed information is recorded [here](https://github.com/openim-sigs/cla/tree/main/signatures/cla.json)'
+ # lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true)
+ # use-dco-flag: true - If you are using DCO instead of CLA
\ No newline at end of file
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..ba89d36
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,65 @@
+# Copyright © 2023 KubeCub open source community. All rights reserved.
+# Licensed under the MIT License (the "License");
+# you may not use this file except in compliance with the License.
+
+name: Comment Lang Detector Release Version
+
+on:
+ push:
+ branches:
+ - 'main'
+ tags:
+ - 'v*'
+
+permissions:
+ contents: write
+ packages: write
+ issues: write
+ id-token: write
+
+jobs:
+ goreleaser:
+ runs-on: ubuntu-latest
+ env:
+ DOCKER_CLI_EXPERIMENTAL: "enabled"
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - name: Setup Golang with cache
+ uses: magnetikonline/action-golang-cache@v3
+ with:
+ go-version: ${{ env.GO_VERSION }}
+
+ - run: git fetch --force --tags
+ - uses: actions/setup-go@v4
+ with:
+ go-version: stable
+
+ - name: Install Dependencies
+ run: |
+ sudo apt update && sudo apt install -y gcc-aarch64-linux-gnu \
+ libbtrfs-dev libgpgme-dev libdevmapper-dev \
+ qemu-user-static binfmt-support
+
+ - name: Login to GitHub Container Registry
+ uses: docker/login-action@v2
+ with:
+ registry: ghcr.io
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.BOT_GITHUB_TOKEN }}
+
+ # 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':
+ distribution: goreleaser
+ version: latest
+ args: release --clean
+
+ env:
+ GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
+ USERNAME: ${{ github.repository_owner }}
+ FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
\ No newline at end of file
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
new file mode 100644
index 0000000..42427ba
--- /dev/null
+++ b/.goreleaser.yaml
@@ -0,0 +1,222 @@
+# Copyright © 2023 KubeCub open source community. All rights reserved.
+# Licensed under the MIT License (the "License");
+# you may not use this file except in compliance with the License.
+
+before:
+ hooks:
+ # You may remove this if you don't use go modules.
+ - make clean
+ - make tidy
+ - make copyright-add
+ # you may remove this if you don't need go generate
+ - make generate
+
+# The lines beneath this are called `modelines`. See `:help modeline`
+# Feel free to remove those if you don't want/use them.
+# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
+# vim: set ts=2 sw=2 tw=0 fo=cnqoj
+
+snapshot:
+ name_template: "{{ incpatch .Version }}-next"
+
+report_sizes: true
+
+# metadata:
+# mod_timestamp: "{{ .CommitTimestamp }}"
+
+# Default: './dist'
+dist: _output/dist
+
+builds:
+ - binary: typecheck
+ id: typecheck
+ main: ./typecheck.go
+ goos:
+ - windows
+ - darwin
+ - linux
+ - freebsd
+ goarch:
+ - amd64
+ - 386
+ - arm
+ - arm64
+ goarm:
+ - 6
+ - 7
+
+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 }}
+ # use zip for windows archives
+ files:
+ - LICENSE
+ - README.md
+ - CHANGELOG/*
+ - docs/*
+ # a more complete example, check the globbing deep dive below
+ - 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
+
+nfpms:
+ - id: packages
+ builds:
+ - typecheck
+ # Your app's vendor.
+ vendor: kubecub
+ homepage: https://github.com/kubecub/typecheck
+ maintainer: kubbot
+ description: |-
+ Comment Lang Detector is a tool to detect the language of comments in code files.
+ Kubecub && cubxxw
+ license: MIT
+ formats:
+ - apk
+ - deb
+ - rpm
+ - termux.deb # Since: v1.11
+ - archlinux # Since: v1.13
+ dependencies:
+ - git
+ recommends:
+ - golang
+
+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
+
+# # semantization
+# snapcrafts:
+# - name_template: "{{ .ProjectName }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
+# summary: sync labels
+# description: |
+# sync labels
+# grade: stable
+# confinement: classic
+# publish: true
+
+# sboms:
+ # - artifacts: archive
+
+# signs:
+# - cmd: cosign
+# stdin: '{{ .Env.COSIGN_PWD }}'
+# args:
+# - "sign-blob"
+# - "--key=cosign.key"
+# - "--output-signature=${signature}"
+# - "${artifact}"
+# - "--yes" # needed on cosign 2.0.0+
+# artifacts: all
+
+# docker_signs:
+
+
+# .goreleaser.yaml
+milestones:
+ # You can have multiple milestone configs
+ -
+ # Repository for the milestone
+ # Default is extracted from the origin remote URL
+ repo:
+ owner: user
+ name: repo
+
+ # 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"
+
+publishers:
+ - name: "fury.io"
+ ids:
+ - packages
+ dir: "{{ dir .ArtifactPath }}"
+ cmd: |
+ bash -c '
+ if [[ "{{ .Tag }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ curl -F package=@{{ .ArtifactName }} https://{{ .Env.FURY_TOKEN }}@push.fury.io/{{ .Env.USERNAME }}/
+ else
+ echo "Skipping deployment: Non-production release detected"
+ fi'
+
+checksum:
+ name_template: "{{ .ProjectName }}_checksums.txt"
+ algorithm: sha256
+
+release:
+ footer: |
+ **Full Changelog**: https://github.com/kubecub/typecheck/compare/{{ .PreviousTag }}...{{ .Tag }}
+
+ ## Helping out
+
+ This release is only possible thanks to **all** the support of some **awesome people**!
\ No newline at end of file