/ .github / workflows / github_release.yml
github_release.yml
 1  name: Project release on Github
 2  
 3  on:
 4    workflow_dispatch:  # this is useful to re-generate the release page without a new tag being pushed
 5    push:
 6      tags:
 7        - "v2.[0-9]+.[0-9]+*"
 8        # Ignore release versions tagged with -rc0 suffix
 9        - "!v2.[0-9]+.[0-9]-rc0"
10  jobs:
11    generate-notes:
12      runs-on: ubuntu-latest
13  
14      steps:
15        - name: Checkout
16          uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17          with:
18            fetch-tags: true
19            fetch-depth: 0  # slow but needed by reno
20  
21        - name: Parse version
22          id: version
23          run: |
24            echo "current_release=$(awk -F \\- '{print $1}' < VERSION.txt)" >> "$GITHUB_OUTPUT"
25            echo "current_pre_release=$(awk -F \\- '{print $2}' < VERSION.txt)" >> "$GITHUB_OUTPUT"
26  
27        - name: Install reno
28          run: |
29            python -m pip install --upgrade pip
30            pip install "reno<5"
31  
32        # Remove next version rc0 tag in the CI environment to prevent reno from assigning notes to future releases.
33        # This ensures release notes are correctly aggregated for the current version.
34        # This is a workaround. Can be removed if the release process is fully aligned with reno.
35        - name: Delete next version rc0 tag in the CI environment
36          run: |
37            # Parse version X.Y.Z and increment Y for next minor version
38            IFS='.' read -r MAJOR MINOR _ <<< "${{ steps.version.outputs.current_release }}"
39            NEXT_MINOR=$((MINOR + 1))
40            NEXT_TAG="v${MAJOR}.${NEXT_MINOR}.0-rc0"
41  
42            if git rev-parse --verify "$NEXT_TAG" >/dev/null 2>&1; then
43              git tag -d "$NEXT_TAG"
44              echo "Deleted local tag $NEXT_TAG"
45            else
46              echo "Tag $NEXT_TAG does not exist locally"
47            fi
48  
49        - name: Generate release notes
50          env:
51  
52            EARLIEST_VERSION: v${{ steps.version.outputs.current_release }}-rc1
53          run: |
54            reno report --no-show-source --ignore-cache --earliest-version "$EARLIEST_VERSION" -o relnotes.rst
55  
56        - name: Convert to Markdown
57          uses: docker://pandoc/core:3.8
58          with:
59            args: "--from rst --to gfm --syntax-highlighting=none --wrap=none relnotes.rst -o relnotes.md"
60  
61        # We copy the relnotes file since the original one cannot be modified due to permissions
62        - name: Copy relnotes file
63          run: |
64            cat relnotes.md > enhanced_relnotes.md
65  
66        - name: Add contributor list
67            # only for minor releases and minor release candidates (not bugfix releases)
68          if: endsWith(steps.version.outputs.current_release, '.0')
69          env:
70            GH_TOKEN: ${{ github.token }}
71            START: v${{ steps.version.outputs.current_release }}-rc0
72            END: ${{ github.ref_name }}
73          run: |
74            JQ_EXPR='[.commits[].author.login]
75              | map(select(. != null and . != "HaystackBot" and . != "dependabot[bot]" and . != "github-actions[bot]"))
76              | unique
77              | sort_by(ascii_downcase)
78              | map("@\(.)")
79              | join(", ")'
80            CONTRIBUTORS=$(gh api "repos/deepset-ai/haystack/compare/$START...$END" \
81              --jq "$JQ_EXPR") || { echo "Unable to fetch contributors"; exit 1; }
82  
83            {
84              echo ""
85              echo "## 💙 Big thank you to everyone who contributed to this release!"
86              echo ""
87              echo "$CONTRIBUTORS"
88            } >> enhanced_relnotes.md
89  
90        - name: Debug
91          run: |
92            cat enhanced_relnotes.md
93  
94        - uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
95          with:
96            bodyFile: "enhanced_relnotes.md"
97            prerelease: ${{ steps.version.outputs.current_pre_release != '' }}
98            allowUpdates: true