diff --git a/dist/index.js b/dist/index.js index 2e69146..b888485 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9726,6 +9726,7 @@ const PULL_REQUEST = Object.freeze({ 'ci', 'docs', 'feature', + 'feat', 'fix', 'perf', 'refactor', @@ -10142,7 +10143,7 @@ function checkedImageOrVideo() { async function hasAnyImageOrVideo() { const rawContent = github.context.payload.pull_request?.body ?? ''; const { repo, owner } = await lib_1.repository.getRepositoryInfo(); - return rawContent.includes(`https://github.com/${owner}/${repo}/assets/`); + return rawContent.includes('https://github.com/user-attachments'); } async function missingImageOrVideo() { if (!checkedImageOrVideo()) { diff --git a/package.json b/package.json index 617d27c..64a0f6c 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "package": "ncc build src/index.ts --license licenses.txt", "package:watch": "npm run package -- --watch", "test": "(jest && make-coverage-badge --output-path ./badges/coverage.svg) || make-coverage-badge --output-path ./badges/coverage.svg", - "all": "npm run format:write && npm run lint && npm run test && npm run package" + "all": "npm run format:write && npm run lint && npm run test && npm run package", + "release": "chmod +x ./scripts/release.sh && ./scripts/release.sh" }, "license": "MIT", "jest": { @@ -87,4 +88,4 @@ "ts-jest": "^29.1.1", "typescript": "^5.2.2" } -} +} \ No newline at end of file diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100644 index 0000000..6f15e11 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,134 @@ +release_type=$1 +version="" + +if [ -z "$release_type" ]; then + release_type="--patch" +fi + +if [ "$release_type" = "--major" ]; then + release_type="major" +elif [ "$release_type" = "--minor" ]; then + release_type="minor" +elif [ "$release_type" = "--patch" ]; then + release_type="patch" +else + if [[ $release_type == v* ]]; then + version=$release_type + else + echo "Invalid release type" + exit 1 + fi +fi + +function git_installed() { + command -v git >/dev/null 2>&1 +} + +function inside_git_repo() { + git rev-parse --is-inside-work-tree >/dev/null 2>&1 +} + +function tag_list() { + git tag --list +} + +function latest_tag() { + local list=$(tag_list) + echo "$list" | sort -V | tail -n 1 +} + +function new_tag() { + if [ -z "$(tag_list)" ]; then + echo "v1.0.0" + else + local release_type=$1 + local latest_tag=$(latest_tag) + + local major=$(echo $latest_tag | cut -d. -f1 | sed 's/v//') + local minor=$(echo $latest_tag | cut -d. -f2) + local patch=$(echo $latest_tag | cut -d. -f3) + + if [ -z "$release_type" ]; then + release_type="patch" + fi + + if [ "$release_type" = "major" ]; then + major=$((major + 1)) + minor=0 + patch=0 + elif [ "$release_type" = "minor" ]; then + minor=$((minor + 1)) + patch=0 + elif [ "$release_type" = "patch" ]; then + patch=$((patch + 1)) + fi + + echo "v$major.$minor.$patch" + fi +} + +function gh_cli_installed() { + command -v gh >/dev/null 2>&1 +} + +function gh_cli_logined() { + gh auth status --show-token >/dev/null 2>&1 +} + +function create_tag_if_not_exists() { + local tag=$1 + local list=$(tag_list) + + if ! echo "$list" | grep -q "^$tag$"; then + git tag $tag + echo "Tag $tag created successfully" + else + echo "Tag $tag already exists" + fi +} + +function create_release_if_not_exists() { + local tag=$1 + if ! gh release view $tag >/dev/null 2>&1; then + gh release create $tag --title $version --generate-notes + echo "Release $tag created successfully" + else + echo "Release $tag already exists" + fi +} + +if git_installed; then + if inside_git_repo; then + if gh_cli_installed; then + if ! gh_cli_logined; then + echo "You are not logged in to GitHub CLI. Please login using 'gh auth login'" + exit 1 + fi + + if [ -z "$version" ]; then + version=$(new_tag $release_type) + fi + + echo "New tag: $version" + read -p "Do you want to create this tag? (y/n) " -n 1 -r + echo "" + + if [[ $REPLY =~ ^[Yy]$ ]]; then + create_tag_if_not_exists $version + + git push origin $version + echo "Tag pushed successfully" + + create_release_if_not_exists $version + else + echo "Tag creation aborted" + fi + else + echo "GitHub CLI is not installed. Please install it from https://cli.github.com" + fi + else + echo "Not inside a git repo" + fi +else + echo "Git is not installed" +fi diff --git a/src/lib/markdownParser.ts b/src/lib/markdownParser.ts index 489087f..d7a8d67 100644 --- a/src/lib/markdownParser.ts +++ b/src/lib/markdownParser.ts @@ -95,7 +95,7 @@ async function hasAnyImageOrVideo() { const rawContent = github.context.payload.pull_request?.body ?? ''; const { repo, owner } = await repository.getRepositoryInfo(); - return rawContent.includes(`https://github.com/${owner}/${repo}/assets/`); + return rawContent.includes('https://github.com/user-attachments'); } async function missingImageOrVideo() {