修改服务监控默认选中为 12 小时。 #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 创建 Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' # 当推送以 v 开头的 tag 时触发 | |
| permissions: | |
| contents: write | |
| jobs: | |
| create-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 检出代码 | |
| - name: 检出代码 | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # 获取完整的 git 历史,用于生成更新日志 | |
| # 获取版本号 | |
| - name: 获取版本号 | |
| id: get_version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "当前版本: ${VERSION}" | |
| # 生成更新日志 | |
| - name: 生成更新日志 | |
| id: changelog | |
| run: | | |
| # 获取上一个 tag | |
| PREVIOUS_TAG=$(git tag --sort=-version:refname | sed -n '2p') | |
| if [ -z "$PREVIOUS_TAG" ]; then | |
| echo "这是第一个 release" | |
| CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges) | |
| else | |
| echo "对比 ${PREVIOUS_TAG} 和当前版本的变更" | |
| CHANGELOG=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges) | |
| fi | |
| # 保存到文件 | |
| echo "${CHANGELOG}" > changelog.txt | |
| cat changelog.txt | |
| # 创建 GitHub Release | |
| - name: 创建 Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: Release ${{ steps.get_version.outputs.version }} | |
| body_path: changelog.txt | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true # 自动生成 release notes | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # 生成总结 | |
| - name: 生成构建总结 | |
| run: | | |
| echo "## Release 创建成功 🎉" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**版本:** ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Release 链接:** https://github.com/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY |