From 8c85141e7ae0fdaf2fc99df020b9fdc58d94a75c Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Sun, 1 Sep 2024 22:44:59 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E5=8F=91=E5=B8=83=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=9B=B4=E6=96=B0=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 35 ++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 8fe826e..2cadd08 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,7 +1,7 @@ name: Docker Publish permissions: - contents: read + contents: write packages: write on: @@ -21,6 +21,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Extract metadata (tags, labels) for Docker id: meta @@ -84,9 +86,38 @@ jobs: - name: Update repo description uses: peter-evans/dockerhub-description@v4 + if: startsWith(github.ref, 'refs/tags/') with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} repository: ${{ env.IMAGE_NAME }} short-description: ${{ github.event.repository.description }} - enable-url-completion: true \ No newline at end of file + enable-url-completion: true + + - name: Get Commit Messages + id: get_commit_messages + run: | + # Get the latest tag + LATEST_TAG=$(git describe --tags --abbrev=0 HEAD^) + + # If there is no latest tag, get only the latest commit message + if [ -z "$LATEST_TAG" ]; then + COMMITS=$(git log -1 --pretty=format:'- %s (%h)') + else + COMMITS=$(git log --pretty=format:'- %s (%h)' --no-merges "$LATEST_TAG"..HEAD) + fi + + # Output Multi-Line String + echo "commits<> $GITHUB_OUTPUT + echo "$COMMITS" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Upload New Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: false + prerelease: false + body: "## What's Changed\n\n${{ steps.get_commit_messages.outputs.commits }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file