Skip to main content
Glama
publish.yaml7 kB
name: Publish Release on: push: branches: - main jobs: publish: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' registry-url: 'https://registry.npmjs.org' - name: Install dependencies run: npm ci - name: Build run: npm run build - name: Configure Git run: | git config --global user.name "Gitea Actions" git config --global user.email "actions@gitea.local" - name: Get npm latest version id: npm_latest run: | PACKAGE_NAME=$(node -p "require('./package.json').name") NPM_LATEST=$(npm view "$PACKAGE_NAME" version --registry https://registry.npmjs.org 2>/dev/null || echo "0.0.0") echo "npm latest version: $NPM_LATEST" echo "npm_latest=$NPM_LATEST" >> $GITHUB_OUTPUT - name: Determine release version id: version run: | # 获取当前版本 CURRENT_VERSION=$(node -p "require('./package.json').version") NPM_LATEST="${{ steps.npm_latest.outputs.npm_latest }}" echo "Current version: $CURRENT_VERSION" echo "npm latest: $NPM_LATEST" # 移除 beta 后缀获取基础版本 BASE_VERSION=$(echo "$CURRENT_VERSION" | sed 's/-beta.*//') echo "Base version: $BASE_VERSION" # 检查是否是 beta 版本转正式版 if [[ "$CURRENT_VERSION" == *"-beta."* ]]; then # beta 版本:直接使用基础版本作为正式版 NEW_VERSION="$BASE_VERSION" echo "Converting beta to release: $CURRENT_VERSION -> $NEW_VERSION" else # 非 beta 版本:基于 npm 最新版本递增 patch MAJOR=$(echo "$NPM_LATEST" | cut -d. -f1) MINOR=$(echo "$NPM_LATEST" | cut -d. -f2) PATCH=$(echo "$NPM_LATEST" | cut -d. -f3) NEXT_PATCH=$((PATCH + 1)) NEW_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}" echo "Non-beta release: incrementing patch $NPM_LATEST -> $NEW_VERSION" fi # 确保新版本大于 npm 最新版本 if [ -n "$NPM_LATEST" ] && [ "$NPM_LATEST" != "0.0.0" ]; then COMPARE_RESULT=$(printf "%s\n%s" "$NEW_VERSION" "$NPM_LATEST" | sort -V | tail -1) if [ "$COMPARE_RESULT" = "$NPM_LATEST" ] && [ "$NEW_VERSION" != "$NPM_LATEST" ]; then echo "::error::New version $NEW_VERSION is not greater than npm latest $NPM_LATEST" exit 1 fi fi echo "New release version: $NEW_VERSION" echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT # 计算下一个开发版本 (patch + 1, beta.0) MAJOR=$(echo "$NEW_VERSION" | cut -d. -f1) MINOR=$(echo "$NEW_VERSION" | cut -d. -f2) PATCH=$(echo "$NEW_VERSION" | cut -d. -f3) NEXT_PATCH=$((PATCH + 1)) NEXT_DEV_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}-beta.0" echo "Next dev version: $NEXT_DEV_VERSION" echo "next_dev_version=$NEXT_DEV_VERSION" >> $GITHUB_OUTPUT # 更新 package.json 为正式版本 npm version "$NEW_VERSION" --no-git-tag-version - name: Make scripts executable run: chmod +x scripts/*.sh || true - name: Update CHANGELOG run: | NEW_VERSION="${{ steps.version.outputs.version }}" echo "正在更新 CHANGELOG..." if [ -f scripts/update-changelog.sh ]; then ./scripts/update-changelog.sh "$NEW_VERSION" else echo "update-changelog.sh 不存在,跳过" fi - name: Update README version and tool count run: | NEW_VERSION="${{ steps.version.outputs.version }}" # 更新版本号 sed -i "s/\*\*当前版本\*\*: v[0-9.]*/**当前版本**: v${NEW_VERSION}/" README.md || true # 更新工具数量 if [ -f scripts/count-tools.sh ]; then ./scripts/count-tools.sh --update fi - name: Publish to npm run: npm publish --tag latest --registry https://registry.npmjs.org/ env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Commit, tag and push to main run: | VERSION="${{ steps.version.outputs.version }}" git add package.json README.md CHANGELOG.md git commit -m "chore: release v${VERSION} [skip ci]" || true git tag -a "v${VERSION}" -m "Release v${VERSION}" git push origin main --tags - name: Sync version to dev branch run: | NEXT_DEV_VERSION="${{ steps.version.outputs.next_dev_version }}" RELEASE_VERSION="${{ steps.version.outputs.version }}" echo "Syncing to dev branch..." git fetch origin dev git checkout dev git pull origin dev # 更新 package.json 为下一个开发版本 npm version "$NEXT_DEV_VERSION" --no-git-tag-version git add package.json git commit -m "chore: set next dev version to ${NEXT_DEV_VERSION} after release v${RELEASE_VERSION} [skip ci]" git push origin dev echo "✓ Dev branch updated to $NEXT_DEV_VERSION" - name: Create Gitea Release uses: https://gitea.com/actions/release-action@main with: title: "v${{ steps.version.outputs.version }}" body: | ## 安装 ```bash npm install -g gitea-mcp-tool@${{ steps.version.outputs.version }} ``` ## 更新 ```bash npm update -g gitea-mcp-tool ``` --- 查看完整更新日志: [Changelog](https://github.com/SupenBysz/gitea-mcp-tool/wiki/Changelog) tag_name: "v${{ steps.version.outputs.version }}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create summary run: | echo "## 正式版本发布成功 🎉" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "**版本号**: \`v${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "**下一个开发版本**: \`${{ steps.version.outputs.next_dev_version }}\`" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "**安装命令**:" >> $GITHUB_STEP_SUMMARY echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY echo "npm install -g gitea-mcp-tool@latest" >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "**npm**: https://www.npmjs.com/package/gitea-mcp-tool" >> $GITHUB_STEP_SUMMARY

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SupenBysz/gitea-mcp-tool'

If you have feedback or need assistance with the MCP directory API, please join our Discord server