From aeb4d6fdcc03649c90740af47b5e60fd07e8b1e3 Mon Sep 17 00:00:00 2001 From: Eduard Aksamitov Date: Wed, 7 Aug 2024 01:33:23 +0300 Subject: [PATCH] ci: update release action --- .github/workflows/create-release.yml | 21 ------------ .github/workflows/release.yml | 49 ++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 21 deletions(-) delete mode 100644 .github/workflows/create-release.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml deleted file mode 100644 index 1bbd708..0000000 --- a/.github/workflows/create-release.yml +++ /dev/null @@ -1,21 +0,0 @@ -on: - push: - tags: - - 'v*' - -name: Create Release - -jobs: - build: - name: Create Release - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Create Release for Tag - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..02320e4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + release: + name: Release On Tag + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v4 + + - name: Extract the changelog + id: changelog + run: | + TAG_NAME=${GITHUB_REF/refs\/tags\//} + READ_SECTION=false + CHANGELOG="" + while IFS= read -r line; do + if [[ "$line" =~ ^#+\ +(.*) ]]; then + if [[ "${BASH_REMATCH[1]}" == "$TAG_NAME" ]]; then + READ_SECTION=true + elif [[ "$READ_SECTION" == true ]]; then + break + fi + elif [[ "$READ_SECTION" == true ]]; then + CHANGELOG+="$line"$'\n' + fi + done < "CHANGELOG.md" + CHANGELOG=$(echo "$CHANGELOG" | awk '/./ {$1=$1;print}') + echo "changelog_content<> $GITHUB_OUTPUT + echo "$CHANGELOG" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create the release + if: steps.changelog.outputs.changelog_content != '' + uses: softprops/action-gh-release@v1 + with: + name: ${{ github.ref_name }} + body: '${{ steps.changelog.outputs.changelog_content }}' + draft: false + prerelease: false