11name : 1. Release-Please
22
33on :
4- push :
5- branches :
6- - main
4+ push :
5+ branches :
6+ - main
77permissions :
8- contents : write
9- pull-requests : write
8+ contents : write
9+ pull-requests : write
1010
1111jobs :
12- release-please :
12+ release :
1313 runs-on : ubuntu-latest
14+ outputs :
15+ upload_url : ${{ steps.release.outputs.upload_url }}
16+ version : ${{ steps.release.outputs.version }}
17+ tag_name : ${{ steps.release.outputs.tag_name }}
18+ release_created : ${{ steps.release.outputs.release_created }}
1419 steps :
15- - uses : googleapis/release-please-action@v4
20+ - id : release
21+ name : release
22+ uses : googleapis/release-please-action@v4
1623 with :
17- token : ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
18- release-type : python
24+ token : ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
25+ config-file : .release-please-config.json
26+ - name : Debug release outputs
27+ run : |
28+ echo "release_created=${{ steps.release.outputs.release_created }}"
29+ echo "version=${{ steps.release.outputs.version }}"
30+ echo "tag_name=${{ steps.release.outputs.tag_name }}"
31+ echo "upload_url=${{ steps.release.outputs.upload_url }}"
32+
33+ upload-assets :
34+ runs-on : ubuntu-latest
35+ needs : release
36+ if : needs.release.outputs.release_created == 'true'
37+ steps :
38+ - name : Checkout code
39+ uses : actions/checkout@v4.2.1
40+
41+ - name : Set up Python
42+ uses : actions/setup-python@v5.2.0
43+ with :
44+ python-version : 3.x
45+
46+ - name : Install Poetry
47+ run : |
48+ pip install poetry
49+ poetry config virtualenvs.create false # Skip creating a virtual environment
50+ env :
51+ POETRY_HOME : ${{ github.workspace }}/.poetry
52+
53+ - name : Install project dependencies
54+ run : poetry install
55+ env :
56+ POETRY_HOME : ${{ github.workspace }}/.poetry
57+
58+ - name : Build package
59+ run : poetry build
60+ env :
61+ POETRY_HOME : ${{ github.workspace }}/.poetry
62+
63+ - name : Set up GitHub CLI
64+ uses : cli/gh-action@v2
65+ with :
66+ token : ${{ secrets.GITHUB_TOKEN }}
67+
68+ - name : Upload dist/* to release
69+ run : |
70+ release_id=$(gh api \
71+ -H "Accept: application/vnd.github+json" \
72+ /repos/${{ github.repository }}/releases/tags/${{ needs.release.outputs.tag_name }} \
73+ --jq .id)
74+
75+ for file in dist/*; do
76+ echo "Uploading $file"
77+ gh api \
78+ --method POST \
79+ -H "Accept: application/vnd.github+json" \
80+ -H "Content-Type: application/octet-stream" \
81+ "/repos/${{ github.repository }}/releases/$release_id/assets?name=$(basename "$file")" \
82+ --input "$file"
83+ done
84+
85+ - name : Append custom release notes
86+ run : |
87+ release_id=$(gh api \
88+ -H "Accept: application/vnd.github+json" \
89+ /repos/${{ github.repository }}/releases/tags/${{ needs.release.outputs.tag_name }} \
90+ --jq .id)
91+
92+ # Fetch existing release body
93+ existing_body=$(gh api /repos/${{ github.repository }}/releases/$release_id --jq .body)
94+
95+ # Create temporary file for new body
96+ tmpfile=$(mktemp)
97+
98+ # Write combined content into the file
99+ {
100+ echo "$existing_body"
101+ echo
102+ echo "Automated Release preparation using Git Tag"
103+ echo " - make sure tests didn't fail"
104+ echo " - needs to be published from draft online"
105+ echo
106+ echo "Install as package using:"
107+ echo '```bash'
108+ echo "pip install git+https://github.com/bensteUEM/ChurchToolsAPI.git@${{ needs.release.outputs.version }}#egg=churchtools-api"
109+ echo '```'
110+ } > "$tmpfile"
111+
112+ # Update the release body using the file
113+ gh api \
114+ -X PATCH \
115+ -H "Accept: application/vnd.github+json" \
116+ /repos/${{ github.repository }}/releases/$release_id \
117+ -F body="$(cat "$tmpfile")"
0 commit comments