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
This commit is contained in:
dsx137 2026-07-02 16:37:28 +08:00 committed by GitHub
parent 2b42ff8c71
commit b67c03b33e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 112 additions and 163 deletions

View File

@ -5,23 +5,23 @@ on:
jobs:
assign-issue:
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')
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
- name: Assign the issue
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-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:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
ISSUE: ${{ github.event.issue.html_url }}

View File

@ -13,7 +13,7 @@ jobs:
steps:
- 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:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}

View File

@ -13,7 +13,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- 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
run: |
@ -66,7 +71,7 @@ jobs:
rm -f "${{ github.event.release.tag_name }}-changelog.md"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7.0.5
uses: peter-evans/create-pull-request@v8.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update CHANGELOG for release ${{ github.event.release.tag_name }}"

View File

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

View File

@ -11,14 +11,13 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.0
uses: actions/checkout@v7.0.0
- name: Get the PR title and extract PR numbers
id: extract_pr_numbers
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
# Get the PR title
PR_TITLE="${{ github.event.pull_request.title }}"
echo "PR Title: $PR_TITLE"
# Extract PR numbers from the title
@ -57,9 +56,8 @@ jobs:
- name: Delete branch after PR close
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: |
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
echo "Branch to delete: $BRANCH_NAME"
git push origin --delete "$BRANCH_NAME"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -35,11 +35,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v7.0.0
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4.36.2
with:
languages: ${{ matrix.language }}
# 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).
# If this step fails, then you should remove it and run the build manually (see below)
- 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.
# 📚 https://git.io/JvXDl
@ -64,4 +64,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4.36.2

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,11 +11,11 @@ jobs:
check_for_first_interaction:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/first-interaction@v1.3.0
- uses: actions/checkout@v7.0.0
- uses: actions/first-interaction@v3.1.0
with:
repo-token: ${{ secrets.BOT_TOKEN }}
pr-message: |
repo_token: ${{ secrets.BOT_TOKEN }}
pr_message: |
Hello! Thank you for your contribution.
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.
issue-message: |
issue_message: |
Hello! Thank you for filing an issue.
If this is a bug report, please include relevant logs to help us debug the problem.

View File

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

View File

@ -24,19 +24,13 @@ fi
cd "$BASE_DIR/.." || exit 1
split_values() {
printf '%s\n' "$1" | tr ', ' '\n\n' | while IFS= read -r value; do
[[ -n "$value" ]] && printf '%s\n' "$value"
done
}
print_command() {
printf '%q ' "$@"
printf '\n'
echo "$1" | grep -o '[^, ]\+'
}
run_or_print() {
if [[ "$DRY_RUN" == "true" ]]; then
print_command "$@"
printf '%q ' "$@"
printf '\n'
else
"$@"
fi
@ -44,7 +38,9 @@ run_or_print() {
build_local() {
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}"
while IFS= read -r built_image; do

View File

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

View File

@ -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

View File

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

View File

@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
@ -35,6 +36,10 @@ type ReleaseData struct {
Published string `json:"published_at"`
}
type GitHubError struct {
Message string `json:"message"`
}
// Method to classify and format release notes.
func (g *GitHubRepo) classifyReleaseNotes(body string) 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)
rePR := regexp.MustCompile(`(?i)in (https://github\.com/[^\s]+/pull/(\d+))`)
// Split the body into individual lines.
lines := strings.Split(body, "\n")
for _, line := range lines {
for line := range strings.SplitSeq(body, "\n") {
// Skip lines that contain "deps: Merge"
if strings.Contains(strings.ToLower(line), "deps: merge #") {
continue
@ -108,7 +110,17 @@ func (g *GitHubRepo) classifyReleaseNotes(body string) map[string][]string {
}
// 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)
// 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)
}
return changelog
return changelog, nil
}
// Method to fetch release data from GitHub API.
@ -165,6 +177,13 @@ func (g *GitHubRepo) fetchReleaseData(version string) (*ReleaseData, error) {
if err != nil {
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
err = json.Unmarshal(body, &releaseData)
@ -188,11 +207,15 @@ func main() {
// Fetch release data (either for latest or specific version)
releaseData, err := repo.fetchReleaseData(version)
if err != nil {
fmt.Println("Error fetching release data:", err)
return
fmt.Fprintln(os.Stderr, "Error fetching release data:", err)
os.Exit(1)
}
// 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)
}