####### 可解析的提交前缀 ######## # ci: 持续集成 # fix: 修改 # feat: 新增 # refactor: 重构 # docs: 文档 # style: 样式 # chore: 其他 # build: 构建 # pref: 优化 # test: 测试 ############################### on: push: tags: - 'v*' # 仅匹配 v* 版本标签,如 v1.0、v20.15.10 name: Create Release permissions: contents: write jobs: verify: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: '8.1' extensions: bcmath, curl, gd, mbstring, openssl coverage: none - name: Install dependencies run: composer install --no-interaction --prefer-dist --no-progress - name: Run tests run: composer test - name: Run static analysis run: composer analyse release: needs: - verify runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Resolve Tags id: tags run: | CURRENT_TAG="${GITHUB_REF_NAME}" PREVIOUS_TAG=$(git tag --list 'v*' --sort=-version:refname | grep -Fxv "$CURRENT_TAG" | head -n 1 || true) echo "CURRENT_TAG=$CURRENT_TAG" >> "$GITHUB_ENV" echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> "$GITHUB_ENV" - name: Generate Release Notes run: | rm -rf log mkdir -p log { echo "## Release ${CURRENT_TAG}" echo if [ -n "${PREVIOUS_TAG}" ]; then echo "Compare: ${PREVIOUS_TAG}..${CURRENT_TAG}" echo git log --pretty=format:'- %s (%h)' "${PREVIOUS_TAG}..${CURRENT_TAG}" else echo "Initial tagged release." echo git log --pretty=format:'- %s (%h)' "${CURRENT_TAG}" fi echo } > "log/${CURRENT_TAG}.md" - name: Create Release uses: softprops/action-gh-release@v2 with: tag_name: ${{ env.CURRENT_TAG }} name: Release ${{ env.CURRENT_TAG }} body_path: log/${{ env.CURRENT_TAG }}.md draft: false prerelease: false