1- name : Create Release
1+ name : 1. Release-Please
2+
23on :
34 push :
4- tags :
5- - ' *'
6-
5+ branches :
6+ - main
7+ permissions :
8+ contents : write
9+ pull-requests : write
10+
711jobs :
8- build :
12+ release-please :
913 runs-on : ubuntu-latest
14+ env :
15+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
1016 steps :
17+ - uses : googleapis/release-please-action@v4
18+ id : release
19+ with :
20+ release-type : python
21+ token : ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
22+
23+ - name : Debug release outputs
24+ run : |
25+ echo "release_created=${{ steps.release.outputs.release_created }}"
26+ echo "version=${{ steps.release.outputs.version }}"
27+ echo "tag_name=${{ steps.release.outputs.tag_name }}"
28+ echo "upload_url=${{ steps.release.outputs.upload_url }}"
29+
1130 - name : Checkout code
31+ if : ${{ steps.release.outputs.release_created }}
1232 uses : actions/checkout@v4.2.1
1333
14- - name : Version from Python
15- run : echo "VERSION=$(python3 -c 'import version; print(version.VERSION)')" >> $GITHUB_ENV
34+ - name : last release tag
35+ if : ${{ steps.release.outputs.release_created }}
36+ id : get_last_release
37+ run : |
38+ LAST_RELEASE_TAG=$(gh release list --limit 2 --json tagName -q '.[1].tagName')
39+ echo "last_release=$LAST_RELEASE_TAG"
40+ echo "last_release=$LAST_RELEASE_TAG" >> $GITHUB_OUTPUT
1641
1742 - name : Set up Python
43+ if : ${{ steps.release.outputs.release_created }}
1844 uses : actions/setup-python@v5.2.0
1945 with :
2046 python-version : 3.x
2147
2248 - name : Install Poetry
49+ if : ${{ steps.release.outputs.release_created }}
2350 run : |
2451 pip install poetry
2552 poetry config virtualenvs.create false # Skip creating a virtual environment
2653 env :
2754 POETRY_HOME : ${{ github.workspace }}/.poetry
2855
2956 - name : Install project dependencies
30- run : |
31- poetry install
57+ if : ${{ steps.release.outputs.release_created }}
58+ run : poetry install
3259 env :
3360 POETRY_HOME : ${{ github.workspace }}/.poetry
3461
3562 - name : Build package
36- run : |
37- poetry build
63+ if : ${{ steps.release.outputs.release_created }}
64+ run : poetry build
3865 env :
3966 POETRY_HOME : ${{ github.workspace }}/.poetry
4067
41- - name : Create Release
42- uses : ncipollo/release-action@v1.14.0
43- with :
44- tag : ${{ env.VERSION}}
45- name : Version ${{env.VERSION}}
46- body : |
47- Automated Release preparation using Git Tag
48- - make sure tests didn't fail
49- - needs to be published from draft online
50-
51- Install as package using:
52- pip install git+https://github.com/bensteUEM/ChurchToolsAPI.git@${{env.VERSION}}#egg=churchtools-api
53-
54- draft : true
55- prerelease : false
56- artifacts : dist/*
68+ - name : Append custom release notes
69+ if : ${{ steps.release.outputs.release_created }}
70+ run : |
71+ release_id=$(gh api \
72+ -H "Accept: application/vnd.github+json" \
73+ /repos/${{ github.repository }}/releases/tags/${{ steps.release.outputs.tag_name }} \
74+ --jq .id)
75+
76+ # Fetch existing release body
77+ existing_body=$(gh api /repos/${{ github.repository }}/releases/$release_id --jq .body)
78+
79+ # Create temporary file for new body
80+ tmpfile=$(mktemp)
81+
82+ # Write combined content into the file
83+ {
84+ echo "$existing_body"
85+ echo
86+ echo "Install as package using:"
87+ echo '```bash'
88+ echo "pip install git+https://github.com/bensteUEM/ChurchToolsAPI.git@${{ steps.release.outputs.tag_name }}#egg=churchtools-api"
89+ echo '```'
90+ echo "**Full Changelog**: https://github.com/bensteUEM/ChurchToolsAPI/compare/${{ steps.get_last_release.outputs.last_release }}...${{ steps.release.outputs.tag_name }}"
91+ } > "$tmpfile"
92+
93+ # Update the release body using the file
94+ gh api \
95+ -X PATCH \
96+ -H "Accept: application/vnd.github+json" \
97+ /repos/${{ github.repository }}/releases/$release_id \
98+ -F body="$(cat "$tmpfile")"
99+
100+ - name : Upload Release Artifact
101+ if : ${{ steps.release.outputs.release_created }}
102+ env :
103+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
104+ run : gh release upload ${{ steps.release.outputs.tag_name }} dist/*
0 commit comments