Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
uses: actions/checkout@v5
with:
ref: ${{ inputs.source_ref || inputs.release_tag || github.ref }}
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v5
Expand Down Expand Up @@ -111,10 +112,55 @@ jobs:
sha256sum * > SHA256SUMS.txt
)

- name: Prepare release notes
shell: bash
run: |
set -euo pipefail

notes_file="$RUNNER_TEMP/codex2api-release-notes.md"
homepage_readme="$RUNNER_TEMP/codex2api-homepage-readme.md"
homepage_readme_zh="$RUNNER_TEMP/codex2api-homepage-readme-zh.md"
version="$VERSION"
previous_tag="$(git tag --sort=-version:refname \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
| grep -Fxv "$version" \
| head -n 1 || true)"

git show origin/main:README.md > "$homepage_readme"
git show origin/main:README.zh-CN.md > "$homepage_readme_zh"

awk '
/^## Custom maintenance$/ { in_section=1 }
in_section && /^## / && $0 != "## Custom maintenance" { exit }
in_section { print }
' "$homepage_readme" > "$notes_file"

printf '\n---\n\n' >> "$notes_file"
awk '
/^## 自定义维护内容$/ { in_section=1 }
in_section && /^## / && $0 != "## 自定义维护内容" { exit }
in_section { print }
' "$homepage_readme_zh" >> "$notes_file"

printf '\n## Custom changes in this release\n\n' >> "$notes_file"
custom_commits=""
if [[ -n "$previous_tag" ]]; then
custom_commits="$(git log --first-parent --format='- %s' \
"$previous_tag..$SOURCE_REF" -- \
':!CHANGELOG.md' ':!docs/**' ':!.github/**' \
| grep -Ev '^- (Merge pull request|chore: sync upstream release|ci:)' || true)"
fi
if [[ -n "$custom_commits" ]]; then
printf '%s\n' "$custom_commits" >> "$notes_file"
else
printf '%s\n' '- No additional custom code changes were recorded for this release.' >> "$notes_file"
fi

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.release_tag || github.ref_name }}
body_path: ${{ runner.temp }}/codex2api-release-notes.md
generate_release_notes: true
files: |
dist/*.tar.gz
Expand Down
Loading