refactor(changelog): modernize generator and workflows (#3752)

* refactor(changelog): modernize generator and workflows

* fix(core): reduce max file descriptor limit

* test(core): use stable Go in build test workflow

* refactor(core): use golang alpine base image

* fix(build): limit docker compose parallelism

* refactor(build): inline compose build logic

* fix(core): reorder Dockerfile ARG declarations
pull/3762/head
dsx137 2 months ago committed by GitHub
parent 2b42ff8c71
commit b67c03b33e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,23 +5,23 @@ on:
jobs: jobs:
assign-issue: assign-issue:
if: | if: |
contains(github.event.comment.body, '/assign') || contains(github.event.comment.body, '/accept') && (contains(github.event.comment.body, '/assign') || contains(github.event.comment.body, '/accept')) &&
!contains(github.event.comment.user.login, 'openim-robot') !contains(github.event.comment.user.login, 'openim-robot')
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
issues: write issues: write
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
- name: Assign the issue - name: Assign the issue
run: | run: |
export LETASE_MILESTONES=$(curl 'https://api.github.com/repos/$OWNER/$PEPO/milestones' | jq -r 'last(.[]).title') export LATEST_MILESTONE=$(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-assignee "${{ github.event.comment.user.login }}"
gh issue edit ${{ github.event.issue.number }} --add-label "accepted" gh issue edit ${{ github.event.issue.number }} --add-label "accepted"
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](https://github.com/$OWNER/$PEPO/milestones), We are looking forward to your PR!" 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 [$LATEST_MILESTONE](https://github.com/$OWNER/$REPO/milestones), We are looking forward to your PR!"
# gh issue edit ${{ github.event.issue.number }} --milestone "$LETASE_MILESTONES" # gh issue edit ${{ github.event.issue.number }} --milestone "$LATEST_MILESTONE"
env: env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }} GH_TOKEN: ${{ secrets.BOT_TOKEN }}
ISSUE: ${{ github.event.issue.html_url }} ISSUE: ${{ github.event.issue.html_url }}

@ -13,7 +13,7 @@ jobs:
steps: steps:
- name: Invite user to join OpenIM Community - name: Invite user to join OpenIM Community
uses: peter-evans/create-or-update-comment@v4 uses: peter-evans/create-or-update-comment@v5.0.0
with: with:
token: ${{ secrets.BOT_GITHUB_TOKEN }} token: ${{ secrets.BOT_GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }} issue-number: ${{ github.event.issue.number }}

@ -13,7 +13,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
- name: Set up Go
uses: actions/setup-go@v6.5.0
with:
go-version-file: go.mod
- name: Run Go Changelog Generator - name: Run Go Changelog Generator
run: | run: |
@ -66,7 +71,7 @@ jobs:
rm -f "${{ github.event.release.tag_name }}-changelog.md" rm -f "${{ github.event.release.tag_name }}-changelog.md"
- name: Create Pull Request - name: Create Pull Request
uses: peter-evans/create-pull-request@v7.0.5 uses: peter-evans/create-pull-request@v8.1.1
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update CHANGELOG for release ${{ github.event.release.tag_name }}" commit-message: "Update CHANGELOG for release ${{ github.event.release.tag_name }}"

@ -18,7 +18,7 @@ jobs:
steps: steps:
- name: "CLA Assistant" - 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' 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.4.0 uses: contributor-assistant/github-action@v2.6.1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.BOT_TOKEN }} PERSONAL_ACCESS_TOKEN: ${{ secrets.BOT_TOKEN }}

@ -11,14 +11,13 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4.2.0 uses: actions/checkout@v7.0.0
- name: Get the PR title and extract PR numbers - name: Get the PR title and extract PR numbers
id: extract_pr_numbers id: extract_pr_numbers
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: | run: |
# Get the PR title
PR_TITLE="${{ github.event.pull_request.title }}"
echo "PR Title: $PR_TITLE" echo "PR Title: $PR_TITLE"
# Extract PR numbers from the title # Extract PR numbers from the title
@ -57,9 +56,8 @@ jobs:
- name: Delete branch after PR close - name: Delete branch after PR close
if: steps.extract_pr_numbers.outputs.proceed == 'true' || contains(github.event.pull_request.labels.*.name, 'milestone-merge') if: steps.extract_pr_numbers.outputs.proceed == 'true' || contains(github.event.pull_request.labels.*.name, 'milestone-merge')
env:
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
run: | run: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
echo "Branch to delete: $BRANCH_NAME" echo "Branch to delete: $BRANCH_NAME"
git push origin --delete "$BRANCH_NAME" git push origin --delete "$BRANCH_NAME"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

@ -35,11 +35,11 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v3 uses: github/codeql-action/init@v4.36.2
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file. # If you wish to specify custom queries, you can do so here or in a config file.
@ -50,7 +50,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below) # If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v3 uses: github/codeql-action/autobuild@v4.36.2
# Command-line programs to run using the OS shell. # Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl # 📚 https://git.io/JvXDl
@ -64,4 +64,4 @@ jobs:
# make release # make release
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3 uses: github/codeql-action/analyze@v4.36.2

@ -17,7 +17,7 @@ jobs:
EXCLUDE_FILES: "*.md *.txt *.html *.css *.min.js *.mdx" EXCLUDE_FILES: "*.md *.txt *.html *.css *.min.js *.mdx"
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v7.0.0
- name: Search for Non-English comments - name: Search for Non-English comments
run: | run: |

@ -22,29 +22,29 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3.3.0 uses: docker/setup-qemu-action@v4.1.0
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.8.0 uses: docker/setup-buildx-action@v4.1.0
- name: Log in to Docker Hub - name: Log in to Docker Hub
uses: docker/login-action@v3.3.0 uses: docker/login-action@v4.2.0
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry - name: Log in to GitHub Container Registry
uses: docker/login-action@v3.3.0 uses: docker/login-action@v4.2.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Aliyun Container Registry - name: Log in to Aliyun Container Registry
uses: docker/login-action@v3.3.0 uses: docker/login-action@v4.2.0
with: with:
registry: registry.cn-hangzhou.aliyuncs.com registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALIREGISTRY_USERNAME }} username: ${{ secrets.ALIREGISTRY_USERNAME }}

@ -22,14 +22,14 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest] os: [ubuntu-latest]
go_version: ["1.25.x"] go_version: ["stable"]
steps: steps:
- name: Checkout Server repository - name: Checkout Server repository
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
- name: Set up Go ${{ matrix.go_version }} - name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v5 uses: actions/setup-go@v6.5.0
with: with:
go-version: ${{ matrix.go_version }} go-version: ${{ matrix.go_version }}
@ -40,7 +40,7 @@ jobs:
go mod download go mod download
- name: Set up infra services - name: Set up infra services
uses: hoverkraft-tech/compose-action@v2.0.1 uses: hoverkraft-tech/compose-action@v3.0.0
with: with:
compose-file: "./docker-compose.yml" compose-file: "./docker-compose.yml"
@ -67,7 +67,7 @@ jobs:
mage check mage check
- name: Checkout Chat repository - name: Checkout Chat repository
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
with: with:
repository: "openimsdk/chat" repository: "openimsdk/chat"
path: "chat-repo" path: "chat-repo"
@ -188,21 +188,21 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest] os: [ubuntu-latest]
go_version: ["1.25.x"] go_version: ["stable"]
steps: steps:
- name: Checkout Server repository - name: Checkout Server repository
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
- name: Checkout SDK repository - name: Checkout SDK repository
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
with: with:
repository: "openimsdk/openim-sdk-core" repository: "openimsdk/openim-sdk-core"
ref: "main" ref: "main"
path: ${{ env.SDK_DIR }} path: ${{ env.SDK_DIR }}
- name: Set up Go ${{ matrix.go_version }} - name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v5 uses: actions/setup-go@v6.5.0
with: with:
go-version: ${{ matrix.go_version }} go-version: ${{ matrix.go_version }}
@ -237,14 +237,14 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
go_version: ["1.25.x"] go_version: ["stable"]
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
- name: Set up Go ${{ matrix.go_version }} - name: Set up Go ${{ matrix.go_version }}
uses: actions/setup-go@v5 uses: actions/setup-go@v6.5.0
with: with:
go-version: ${{ matrix.go_version }} go-version: ${{ matrix.go_version }}

@ -26,7 +26,7 @@ jobs:
issues: write issues: write
steps: steps:
- name: Add comment - name: Add comment
uses: peter-evans/create-or-update-comment@v4 uses: peter-evans/create-or-update-comment@v5.0.0
with: with:
issue-number: ${{ github.event.issue.number }} issue-number: ${{ github.event.issue.number }}
token: ${{ secrets.BOT_TOKEN }} token: ${{ secrets.BOT_TOKEN }}

@ -40,7 +40,7 @@ jobs:
touch ${{ env.TEMP_DIR }}/created_pr_number.txt touch ${{ env.TEMP_DIR }}/created_pr_number.txt
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
with: with:
fetch-depth: 0 fetch-depth: 0
token: ${{ secrets.BOT_TOKEN }} token: ${{ secrets.BOT_TOKEN }}

@ -14,7 +14,6 @@ on:
default: "v3.8.3" default: "v3.8.3"
env: env:
GO_VERSION: "1.22"
IMAGE_NAME: "openim-server" IMAGE_NAME: "openim-server"
# IMAGE_NAME: ${{ github.event.repository.name }} # IMAGE_NAME: ${{ github.event.repository.name }}
DOCKER_BUILDKIT: 1 DOCKER_BUILDKIT: 1
@ -25,22 +24,22 @@ jobs:
if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.merged == false) }} if: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.merged == false) }}
steps: steps:
- name: Checkout main repository - name: Checkout main repository
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
with: with:
path: main-repo path: main-repo
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3.3.0 uses: docker/setup-qemu-action@v4.1.0
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v4.1.0
with: with:
driver-opts: network=host driver-opts: network=host
- name: Extract metadata for Docker - name: Extract metadata for Docker
id: meta id: meta
uses: docker/metadata-action@v5.6.0 uses: docker/metadata-action@v6.1.0
with: with:
images: | images: |
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
@ -80,7 +79,7 @@ jobs:
docker image ls | grep openim docker image ls | grep openim
- name: Checkout compose repository - name: Checkout compose repository
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
with: with:
repository: "openimsdk/openim-docker" repository: "openimsdk/openim-docker"
path: "compose-repo" path: "compose-repo"
@ -134,20 +133,20 @@ jobs:
# fi # fi
- name: Log in to Docker Hub - name: Log in to Docker Hub
uses: docker/login-action@v3.3.0 uses: docker/login-action@v4.2.0
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry - name: Log in to GitHub Container Registry
uses: docker/login-action@v3.3.0 uses: docker/login-action@v4.2.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Aliyun Container Registry - name: Log in to Aliyun Container Registry
uses: docker/login-action@v3.3.0 uses: docker/login-action@v4.2.0
with: with:
registry: registry.cn-hangzhou.aliyuncs.com registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALIREGISTRY_USERNAME }} username: ${{ secrets.ALIREGISTRY_USERNAME }}

@ -11,11 +11,11 @@ jobs:
contents: read contents: read
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
- name: Fetch All Issues and PRs - name: Fetch All Issues and PRs
id: fetch_issues_prs id: fetch_issues_prs
uses: actions/github-script@v7.0.1 uses: actions/github-script@v9.0.0
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
@ -38,7 +38,7 @@ jobs:
- name: Fetch All Labels - name: Fetch All Labels
id: fetch_labels id: fetch_labels
uses: actions/github-script@v7.0.1 uses: actions/github-script@v9.0.0
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
@ -52,7 +52,7 @@ jobs:
result-encoding: string result-encoding: string
- name: Remove Unused Labels - name: Remove Unused Labels
uses: actions/github-script@v7.0.1 uses: actions/github-script@v9.0.0
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |

@ -12,11 +12,11 @@ jobs:
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
- name: Fetch Closed Issues with lifecycle/stale Label - name: Fetch Closed Issues with lifecycle/stale Label
id: fetch_issues id: fetch_issues
uses: actions/github-script@v7 uses: actions/github-script@v9.0.0
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
@ -40,7 +40,7 @@ jobs:
echo "Issue numbers: ${{ steps.fetch_issues.outputs.result }}" echo "Issue numbers: ${{ steps.fetch_issues.outputs.result }}"
- name: Reopen Issues - name: Reopen Issues
uses: actions/github-script@v7 uses: actions/github-script@v9.0.0
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
@ -59,7 +59,7 @@ jobs:
} }
- name: Remove lifecycle/stale Label - name: Remove lifecycle/stale Label
uses: actions/github-script@v7 uses: actions/github-script@v9.0.0
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |

@ -12,7 +12,7 @@ jobs:
steps: steps:
# Step 1: Checkout the original repository's code # Step 1: Checkout the original repository's code
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v7.0.0
with: with:
fetch-depth: 0 fetch-depth: 0
# submodules: "recursive" # submodules: "recursive"
@ -73,7 +73,7 @@ jobs:
# Step 7: Find and Publish Draft Release # Step 7: Find and Publish Draft Release
- name: Find and Publish Draft Release - name: Find and Publish Draft Release
uses: actions/github-script@v7 uses: actions/github-script@v9.0.0
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |

@ -11,11 +11,11 @@ jobs:
check_for_first_interaction: check_for_first_interaction:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v7.0.0
- uses: actions/first-interaction@v1.3.0 - uses: actions/first-interaction@v3.1.0
with: with:
repo-token: ${{ secrets.BOT_TOKEN }} repo_token: ${{ secrets.BOT_TOKEN }}
pr-message: | pr_message: |
Hello! Thank you for your contribution. Hello! Thank you for your contribution.
If you are fixing a bug, please reference the issue number in the description. If you are fixing a bug, please reference the issue number in the description.
@ -26,7 +26,7 @@ jobs:
Please leave your information in the [✨ discussions](https://github.com/orgs/OpenIMSDK/discussions/426), we expect anyone to join OpenIM developer community. Please leave your information in the [✨ discussions](https://github.com/orgs/OpenIMSDK/discussions/426), we expect anyone to join OpenIM developer community.
issue-message: | issue_message: |
Hello! Thank you for filing an issue. Hello! Thank you for filing an issue.
If this is a bug report, please include relevant logs to help us debug the problem. If this is a bug report, please include relevant logs to help us debug the problem.

@ -1,4 +1,4 @@
FROM golang:1.25-alpine AS builder FROM golang:alpine AS builder
ARG RELEASE=false ARG RELEASE=false
ARG COMPRESS=false ARG COMPRESS=false

@ -24,19 +24,13 @@ fi
cd "$BASE_DIR/.." || exit 1 cd "$BASE_DIR/.." || exit 1
split_values() { split_values() {
printf '%s\n' "$1" | tr ', ' '\n\n' | while IFS= read -r value; do echo "$1" | grep -o '[^, ]\+'
[[ -n "$value" ]] && printf '%s\n' "$value"
done
}
print_command() {
printf '%q ' "$@"
printf '\n'
} }
run_or_print() { run_or_print() {
if [[ "$DRY_RUN" == "true" ]]; then if [[ "$DRY_RUN" == "true" ]]; then
print_command "$@" printf '%q ' "$@"
printf '\n'
else else
"$@" "$@"
fi fi
@ -44,7 +38,9 @@ run_or_print() {
build_local() { build_local() {
echo -e "${CYAN}Building all services...${NO_COLOR}" echo -e "${CYAN}Building all services...${NO_COLOR}"
RELEASE="$RELEASE" docker compose -f "$COMPOSE_FILE" build while IFS= read -r service; do
RELEASE="$RELEASE" docker compose -f "$COMPOSE_FILE" build "$service"
done < <(docker compose -f "$COMPOSE_FILE" config --services)
echo -e "${CYAN}Tagging compatibility images for Kubernetes...${NO_COLOR}" echo -e "${CYAN}Tagging compatibility images for Kubernetes...${NO_COLOR}"
while IFS= read -r built_image; do while IFS= read -r built_image; do

@ -1,8 +1,4 @@
FROM golang:1.25-alpine AS builder FROM golang:alpine AS builder
ARG CMD_PATH
ARG BINARY_NAME
ARG RELEASE=false
ENV SERVER_DIR=/openim-server ENV SERVER_DIR=/openim-server
WORKDIR $SERVER_DIR WORKDIR $SERVER_DIR
@ -10,6 +6,10 @@ WORKDIR $SERVER_DIR
COPY . . COPY . .
RUN go mod tidy RUN go mod tidy
ARG CMD_PATH
ARG BINARY_NAME
ARG RELEASE=false
RUN if [ "$RELEASE" = "true" ]; then \ RUN if [ "$RELEASE" = "true" ]; then \
go build -trimpath -ldflags "-s -w" -o _output/${BINARY_NAME} ./${CMD_PATH}; \ go build -trimpath -ldflags "-s -w" -o _output/${BINARY_NAME} ./${CMD_PATH}; \
else \ else \

@ -1,72 +0,0 @@
services:
openim-api:
build:
platforms:
- linux/amd64
- linux/arm64
openim-crontask:
build:
platforms:
- linux/amd64
- linux/arm64
openim-msggateway:
build:
platforms:
- linux/amd64
- linux/arm64
openim-msgtransfer:
build:
platforms:
- linux/amd64
- linux/arm64
openim-push:
build:
platforms:
- linux/amd64
- linux/arm64
openim-rpc-auth:
build:
platforms:
- linux/amd64
- linux/arm64
openim-rpc-conversation:
build:
platforms:
- linux/amd64
- linux/arm64
openim-rpc-friend:
build:
platforms:
- linux/amd64
- linux/arm64
openim-rpc-group:
build:
platforms:
- linux/amd64
- linux/arm64
openim-rpc-msg:
build:
platforms:
- linux/amd64
- linux/arm64
openim-rpc-third:
build:
platforms:
- linux/amd64
- linux/arm64
openim-rpc-user:
build:
platforms:
- linux/amd64
- linux/arm64

@ -15,4 +15,4 @@ toolBinaries:
- check-free-memory - check-free-memory
- check-component - check-component
- seq - seq
maxFileDescriptors: 100000 maxFileDescriptors: 10000

@ -2,6 +2,7 @@ package main
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -35,6 +36,10 @@ type ReleaseData struct {
Published string `json:"published_at"` Published string `json:"published_at"`
} }
type GitHubError struct {
Message string `json:"message"`
}
// Method to classify and format release notes. // Method to classify and format release notes.
func (g *GitHubRepo) classifyReleaseNotes(body string) map[string][]string { func (g *GitHubRepo) classifyReleaseNotes(body string) map[string][]string {
result := map[string][]string{ result := map[string][]string{
@ -49,10 +54,7 @@ func (g *GitHubRepo) classifyReleaseNotes(body string) map[string][]string {
// Regular expression to extract PR number and URL (case insensitive) // Regular expression to extract PR number and URL (case insensitive)
rePR := regexp.MustCompile(`(?i)in (https://github\.com/[^\s]+/pull/(\d+))`) rePR := regexp.MustCompile(`(?i)in (https://github\.com/[^\s]+/pull/(\d+))`)
// Split the body into individual lines. for line := range strings.SplitSeq(body, "\n") {
lines := strings.Split(body, "\n")
for _, line := range lines {
// Skip lines that contain "deps: Merge" // Skip lines that contain "deps: Merge"
if strings.Contains(strings.ToLower(line), "deps: merge #") { if strings.Contains(strings.ToLower(line), "deps: merge #") {
continue continue
@ -108,7 +110,17 @@ func (g *GitHubRepo) classifyReleaseNotes(body string) map[string][]string {
} }
// Method to generate the final changelog. // Method to generate the final changelog.
func (g *GitHubRepo) generateChangelog(tag, date, htmlURL, body string) string { func (g *GitHubRepo) generateChangelog(tag, date, htmlURL, body string) (string, error) {
if tag == "" {
return "", errors.New("release tag is empty")
}
if len(date) < 10 {
return "", fmt.Errorf("release published_at is invalid: %q", date)
}
if htmlURL == "" {
return "", errors.New("release html_url is empty")
}
sections := g.classifyReleaseNotes(body) sections := g.classifyReleaseNotes(body)
// Convert ISO 8601 date to simpler format (YYYY-MM-DD) // Convert ISO 8601 date to simpler format (YYYY-MM-DD)
@ -140,7 +152,7 @@ func (g *GitHubRepo) generateChangelog(tag, date, htmlURL, body string) string {
changelog += fmt.Sprintf("**Full Changelog**: %s\n", g.FullChangelog) changelog += fmt.Sprintf("**Full Changelog**: %s\n", g.FullChangelog)
} }
return changelog return changelog, nil
} }
// Method to fetch release data from GitHub API. // Method to fetch release data from GitHub API.
@ -165,6 +177,13 @@ func (g *GitHubRepo) fetchReleaseData(version string) (*ReleaseData, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
var githubError GitHubError
if err := json.Unmarshal(body, &githubError); err == nil && githubError.Message != "" {
return nil, fmt.Errorf("github api returned %s: %s", resp.Status, githubError.Message)
}
return nil, fmt.Errorf("github api returned %s", resp.Status)
}
var releaseData ReleaseData var releaseData ReleaseData
err = json.Unmarshal(body, &releaseData) err = json.Unmarshal(body, &releaseData)
@ -188,11 +207,15 @@ func main() {
// Fetch release data (either for latest or specific version) // Fetch release data (either for latest or specific version)
releaseData, err := repo.fetchReleaseData(version) releaseData, err := repo.fetchReleaseData(version)
if err != nil { if err != nil {
fmt.Println("Error fetching release data:", err) fmt.Fprintln(os.Stderr, "Error fetching release data:", err)
return os.Exit(1)
} }
// Generate and print the formatted changelog // Generate and print the formatted changelog
changelog := repo.generateChangelog(releaseData.TagName, releaseData.Published, releaseData.HtmlUrl, releaseData.Body) changelog, err := repo.generateChangelog(releaseData.TagName, releaseData.Published, releaseData.HtmlUrl, releaseData.Body)
if err != nil {
fmt.Fprintln(os.Stderr, "Error generating changelog:", err)
os.Exit(1)
}
fmt.Println(changelog) fmt.Println(changelog)
} }

Loading…
Cancel
Save