diff --git a/.github/workflows/Auto Release.yml b/.github/workflows/Auto Release.yml index d3c27f9..8158396 100644 --- a/.github/workflows/Auto Release.yml +++ b/.github/workflows/Auto Release.yml @@ -2,37 +2,52 @@ name: Auto Release on: push: - branches: - - master + tags: + - 'release-v*' jobs: release: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 + with: + fetch-depth: 0 - - name: Generate release notes - id: generate_notes - run: | - echo "::set-output name=notes::$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:'- %s')" - shell: bash + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' - - name: Extract first line of commit message - id: extract_line + - name: Generate Changelog + id: changelog run: | - echo "::set-output name=line::$(echo "${{ github.event.head_commit.message }}" | head -n1)" + npm install -g conventional-changelog-cli + conventional-changelog -p angular -i CHANGELOG.md -s -r 0 + cp CHANGELOG.md ./tmp_changelog + + - name: Set Release Name shell: bash + id: set_release_name + run: echo "tag=$(echo $GITHUB_REF | sed 's|refs/tags/||')" >> $GITHUB_OUTPUT - name: Create Release id: create_release - uses: actions/create-release@v1 - if: contains(github.event.head_commit.message, 'release-v') + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') env: + # GITHUB_TOKEN GITHUB_TOKEN: ${{ secrets.GB_TOKEN }} with: - tag_name: ${{ steps.extract_line.outputs.line }} - release_name: ${{ steps.extract_line.outputs.line }} - body: ${{ steps.generate_notes.outputs.notes }} + # tag_name: 使用 tag + tag_name: ${{ github.ref }} + # release_name: 使用 tag + name: ${{ steps.set_release_name.outputs.tag }} + # body: 使用 changelog + body_path: ./tmp_changelog + # 草稿 draft: false + # 预发布 prerelease: false + # 自动生成 release notes + generate_release_notes: true \ No newline at end of file