11name : Pre-release - Bump version & draft release
2+
23on :
34 workflow_dispatch :
45 inputs :
56 target_branch :
67 description : >
78 "This workflow will create a commit to bump version on a branch.
8- Enter the target branch: main for Saas , or release/XX.Y for a LTS version: "
9+ Enter the target branch: main for SaaS , or release/XX.Y for an LTS version: "
910 required : true
1011 type : string
1112 default : " main"
1213
14+ permissions :
15+ contents : write
16+
1317jobs :
1418 pre_release :
1519 runs-on : ubuntu-latest
1620 name : Bump version & draft release
21+
1722 steps :
18- - uses : actions/checkout@v4
23+ - name : Checkout target branch
24+ uses : actions/checkout@v4
1925 with :
20- ref : ${{ github.event.inputs.target_branch}}
26+ ref : ${{ github.event.inputs.target_branch }}
27+ token : ${{ secrets.RELEASE_BOT_PAT }} # <<< service PAT
2128
2229 - name : Set up Python
2330 uses : actions/setup-python@v5
@@ -32,49 +39,63 @@ jobs:
3239
3340 - name : Set git identity
3441 run : |
35- git config user.name github-actions
36- git config user.email github-actions@ github.com
42+ git config user.name "kili-release-bot"
43+ git config user.email "[email protected] . github.com" 3744
3845 - name : Add the bump commit
46+ env :
47+ GH_TOKEN : ${{ secrets.RELEASE_BOT_PAT }}
48+ shell : bash
3949 run : |
50+ set -euo pipefail
51+
4052 git fetch --quiet
4153
4254 curl https://raw.githubusercontent.com/kili-technology/kili-python-sdk/main/.github/scripts/utils.sh --output utils.sh
43- source ./utils.sh # to get the bump_version function
55+ source ./utils.sh # exposes bump_version
4456
45- # create bump commit
57+ # create bump commit (major / minor / patch)
4658 new_version=$(bump_version commit patch)
4759 echo "New version (bump_version): $new_version"
4860
49- git push
50- env :
51- GH_TOKEN : ${{ github.token }} # needed for gh cli
61+ # Push back to the same branch explicitly
62+ git push origin HEAD:${{ github.event.inputs.target_branch }}
5263
53- - name : create draft release
64+ - name : Create tag and draft release
65+ env :
66+ GH_TOKEN : ${{ secrets.RELEASE_BOT_PAT }} # used by gh CLI
67+ shell : bash
5468 run : |
69+ set -euo pipefail
70+
5571 curl https://raw.githubusercontent.com/kili-technology/kili-python-sdk/main/.github/scripts/utils.sh --output utils.sh
56- source ./utils.sh # to get the get_sdk_version_from_pyproject_toml function
72+ source ./utils.sh
5773
58- # Get release version
74+ # Get release version from pyproject.toml (now bumped)
5975 release_version=$(get_sdk_version_from_pyproject_toml)
6076 echo "Release version: $release_version"
6177
62- # tag and push the tag
63- # -a to create an annotated tag
64- git fetch --quiet
65- git tag -a $release_version -m "Release $release_version"
66- git push origin $release_version
78+ # Get last release tag for release notes range
79+ latest_release=$(get_last_release_tag_github)
80+ echo "Latest release tag: $latest_release"
6781
68- # create draft release
69- link_to_draft=$(gh release create $release_version --draft --title "Release $release_version" --generate-notes --notes-start-tag $latest_release)
70- echo "Link to draft release: $link_to_draft"
82+ git fetch --tags --quiet
83+
84+ # Create annotated tag on this commit & push it
85+ git tag -a "$release_version" -m "Release $release_version"
86+ git push origin "$release_version"
7187
72- # filter the result to get the link
73- # will match any string that starts with https:// and contains any number of characters that are not spaces.
88+ # Create draft release
89+ link_to_draft=$(gh release create "$release_version" \
90+ --draft \
91+ --title "Release $release_version" \
92+ --generate-notes \
93+ --notes-start-tag "$latest_release")
94+
95+ # Extract URL from gh output
7496 link_to_draft=$(echo "$link_to_draft" | grep -o 'https://[^ ]*')
97+
7598 echo "Link to draft release: $link_to_draft"
7699
77- echo "LINK_TO_DRAFT=$link_to_draft" >> $GITHUB_ENV
78- echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
79- env :
80- GH_TOKEN : ${{ github.token }} # needed for gh cli
100+ echo "LINK_TO_DRAFT=$link_to_draft" >> "$GITHUB_ENV"
101+ echo "RELEASE_VERSION=$release_version" >> "$GITHUB_ENV"
0 commit comments