Skip to content
Merged
Show file tree
Hide file tree
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
83 changes: 83 additions & 0 deletions .github/release-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
## ${TAG_NAME} Release Notes

<!--
Maintainer guide (please read before publishing; this HTML comment is
invisible in the rendered Release page):

1. This file is the skeleton for the draft Release body. It is rendered
by the `release` job in .github/workflows/release.yml using Python's
string.Template.safe_substitute.
2. Placeholders that get substituted automatically at render time:
TAG_NAME current tag, e.g. vX.Y.Z
VERSION version without the leading `v`, e.g. X.Y.Z
FULL_CHANGELOG_URL compare URL against the previous tag
Note: these three names must appear as `$` followed by braces in the
template body to be substituted; this comment intentionally spells
them without that syntax so it does not substitute itself.
3. HTML comments under each section are classification hints. Delete or
keep them before publishing (kept comments stay invisible to readers
and save effort on the next release).
4. If a section has no content for this release, delete it entirely or
write "None".
5. Classification follows conventional-commit PR title prefixes:
feat(scope): -> ✨ Features
fix(scope): -> 🐛 Bug Fixes
refactor(scope): -> ♻️ Refactoring
docs(scope): -> 📚 Documentation
chore/ci/build/test: -> 🔧 CI & Chore
6. Highlights is the "elevator pitch" — pick 1-3 changes users should
care about most (new capabilities, breaking changes, or fixes with
wide impact).
7. For pre-release versions (tag contains a/b/rc/post), tick
"Set as a pre-release" on the draft page so this release does not
occupy the /releases/latest endpoint.
-->

### 🚀 Highlights

-

### ✨ Features

-

### ♻️ Refactoring

-

### 🐛 Bug Fixes

-

### 📚 Documentation

-

### 🔧 CI & Chore

-

### ⚠️ Breaking Changes

None

---

### 📦 Installation

```bash
pip install --upgrade dashscope==${VERSION}
```

### 👥 Contributors

Thanks to all the contributors who made this release possible:

<!-- List @handles here. On the draft page, the "Generate release notes"
button in the top-right can auto-populate New Contributors. -->

-

### 📝 Full Changelog

${FULL_CHANGELOG_URL}
128 changes: 128 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Build and Release

on:
push:
tags:
- 'v*'

permissions:
contents: read

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Verify tag commit is on main
run: |
git fetch origin main
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
echo "::error::Tag $GITHUB_REF_NAME does not point to a commit on main."
exit 1
fi

- name: Verify version matches tag
run: |
tag_version="${GITHUB_REF_NAME#v}"
pkg_version=$(python -c "exec(open('dashscope/version.py').read()); print(__version__)")
if [ "$tag_version" != "$pkg_version" ]; then
echo "::error::Tag $GITHUB_REF_NAME (=$tag_version) != dashscope/version.py (=$pkg_version)"
exit 1
fi

package:
needs: [validate]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- run: python -m pip install build twine
- run: python -m build
- run: twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: python-distribution
path: |
dist/*.whl
dist/*.tar.gz

pypi:
needs: [package]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/dashscope
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: python-distribution
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

release:
needs: [package]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/download-artifact@v4
with:
name: python-distribution
path: dist/

- name: Render release notes
env:
TAG_NAME: ${{ github.ref_name }}
run: |
git fetch --tags --force
prev_tag=$(git tag --sort=-v:refname | grep -v "^${TAG_NAME}$" | head -1)
if [ -n "$prev_tag" ]; then
changelog_url="https://github.com/${{ github.repository }}/compare/${prev_tag}...${TAG_NAME}"
else
changelog_url="https://github.com/${{ github.repository }}/commits/${TAG_NAME}"
fi
python - "$TAG_NAME" "$changelog_url" <<'PYEOF'
import sys
from string import Template
from pathlib import Path

tag = sys.argv[1]
changelog = sys.argv[2]
version = tag.lstrip("v")
tpl = Template(Path(".github/release-template.md").read_text())
body = tpl.safe_substitute(
TAG_NAME=tag, VERSION=version, FULL_CHANGELOG_URL=changelog,
)
Path("release-body.md").write_text(body)
PYEOF

- name: Detect pre-release
id: prerelease
env:
TAG_NAME: ${{ github.ref_name }}
run: |
if echo "$TAG_NAME" | grep -qE '(a|b|rc|post|dev)[0-9]'; then
echo "flag=true" >> "$GITHUB_OUTPUT"
else
echo "flag=false" >> "$GITHUB_OUTPUT"
fi

- name: Create draft GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: release-body.md
files: dist/*
draft: true
prerelease: ${{ steps.prerelease.outputs.flag }}
16 changes: 2 additions & 14 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,10 @@ jobs:
legacy:
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, 'docs:')) }}

runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
matrix:
# ubuntu-latest (26.04) ships no CPython 3.9 build, so pin the
# still-supported 3.9 leg to 24.04 and keep the rest on latest.
include:
- os: ubuntu-24.04
python-version: '3.9'
- os: ubuntu-latest
python-version: '3.10'
- os: ubuntu-latest
python-version: '3.11'
- os: ubuntu-latest
python-version: '3.12'
- os: ubuntu-latest
python-version: '3.13'
python-version: ['3.11']

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion dashscope/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright (c) Alibaba, Inc. and its affiliates.

__version__ = "2.1.0"
__version__ = "2.1.0rc1"
Loading