name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate Changelog
id: changelog
run: |
# Extract version from tag
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Generate changelog from commits
PREV_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1) 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges)
else
CHANGELOG=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges)
fi
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ steps.changelog.outputs.version }}
body: |
## 🎉 Release ${{ steps.changelog.outputs.version }}
### 📝 Changes
${{ steps.changelog.outputs.changelog }}
### 📦 Installation
```bash
git clone -b ${{ steps.changelog.outputs.version }} https://github.com/dsphper/lanhu-mcp.git
cd lanhu-mcp
pip install -r requirements.txt
```
### 🐳 Docker
```bash
docker pull ghcr.io/dsphper/lanhu-mcp:${{ steps.changelog.outputs.version }}
```
### 📖 Documentation
See [README.md](https://github.com/dsphper/lanhu-mcp/blob/${{ steps.changelog.outputs.version }}/README.md) for full documentation.
draft: false
prerelease: false
docker-publish:
name: Publish Docker Image
runs-on: ubuntu-latest
needs: create-release
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
pypi-publish:
name: Publish to PyPI (Future)
runs-on: ubuntu-latest
needs: create-release
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: |
# 当 pyproject.toml 准备就绪时,取消注释:
# When pyproject.toml build config is ready, uncomment:
# python -m build
echo "✅ PyPI publishing will be enabled in future releases | PyPI 发布将在未来版本中启用"
# Uncomment when ready to publish to PyPI
# - name: Publish to PyPI
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
# run: |
# twine upload dist/*