88 lines
3.0 KiB
YAML
88 lines
3.0 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 9
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Extract version from tag
|
|
id: version
|
|
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Pack templates (release mode)
|
|
run: |
|
|
node scripts/pack-template.js react-vite --release
|
|
node scripts/pack-template.js vue3-vite --release
|
|
node scripts/pack-template.js react-next --release
|
|
|
|
- name: List packed files
|
|
run: ls -lh zip/
|
|
|
|
- name: Generate release notes
|
|
id: notes
|
|
run: |
|
|
VERSION=${{ steps.version.outputs.VERSION }}
|
|
TAG=${GITHUB_REF_NAME}
|
|
NOTES="## ${TAG}"$'\n\n'
|
|
NOTES+="### 📦 Download URLs"$'\n\n'
|
|
NOTES+="| Template | Version | Download |"$'\n'
|
|
NOTES+="|----------|---------|----------|"$'\n'
|
|
NOTES+="| React + Vite | ${VERSION} | \`react-vite-template_${VERSION}.zip\` |"$'\n'
|
|
NOTES+="| Vue 3 + Vite | ${VERSION} | \`vue3-vite-template_${VERSION}.zip\` |"$'\n'
|
|
NOTES+="| React + Next.js | ${VERSION} | \`react-next-template_${VERSION}.zip\` |"$'\n\n'
|
|
NOTES+="### 🔗 快速下载"$'\n\n'
|
|
NOTES+="\`\`\`bash"$'\n'
|
|
NOTES+="# 指定版本"$'\n'
|
|
NOTES+="curl -sLO https://github.com/nuwax-ai/xagi-frontend-templates/releases/download/${TAG}/react-vite-template_${VERSION}.zip"$'\n\n'
|
|
NOTES+="# 获取最新版本"$'\n'
|
|
NOTES+="curl -sL https://raw.githubusercontent.com/nuwax-ai/xagi-frontend-templates/main/latest.json | jq -r '.templates[\"react-vite\"].url' | xargs curl -sLO"$'\n'
|
|
NOTES+='\`\`\'
|
|
echo "NOTES<<EOFMARKER" >> "$GITHUB_OUTPUT"
|
|
echo "$NOTES" >> "$GITHUB_OUTPUT"
|
|
echo "EOFMARKER" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Create GitHub Release
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
gh release create ${GITHUB_REF_NAME} \
|
|
zip/*.zip \
|
|
--title "${GITHUB_REF_NAME}" \
|
|
--notes "${{ steps.notes.outputs.NOTES }}"
|
|
|
|
- name: Generate latest.json
|
|
run: node scripts/generate-latest-json.js ${{ steps.version.outputs.VERSION }}
|
|
|
|
- name: Commit latest.json back to main
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git checkout main
|
|
git add latest.json
|
|
git diff --cached --quiet || git commit -m "chore: update latest.json for ${GITHUB_REF_NAME}"
|
|
git push origin main
|