diff --git a/.github/release-template.md b/.github/release-template.md new file mode 100644 index 00000000..55cc4faf --- /dev/null +++ b/.github/release-template.md @@ -0,0 +1,83 @@ +## ${TAG_NAME} Release Notes + + + +### 🚀 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: + + + +- + +### 📝 Full Changelog + +${FULL_CHANGELOG_URL} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..256a0d4d --- /dev/null +++ b/.github/workflows/release.yml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index d6c14d06..8ec5ac8f 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -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 diff --git a/dashscope/version.py b/dashscope/version.py index 88cef6b2..acfb052a 100644 --- a/dashscope/version.py +++ b/dashscope/version.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- # Copyright (c) Alibaba, Inc. and its affiliates. -__version__ = "2.1.0" +__version__ = "2.1.0rc1"