-
Notifications
You must be signed in to change notification settings - Fork 6
104 lines (89 loc) · 3.54 KB
/
release.yml
File metadata and controls
104 lines (89 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: 1. Release-Please
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
release-please:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
release-type: python
token: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
- name: Debug release outputs
run: |
echo "release_created=${{ steps.release.outputs.release_created }}"
echo "version=${{ steps.release.outputs.version }}"
echo "tag_name=${{ steps.release.outputs.tag_name }}"
echo "upload_url=${{ steps.release.outputs.upload_url }}"
- name: Checkout code
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4.2.1
- name: last release tag
if: ${{ steps.release.outputs.release_created }}
id: get_last_release
run: |
LAST_RELEASE_TAG=$(gh release list --limit 2 --json tagName -q '.[1].tagName')
echo "last_release=$LAST_RELEASE_TAG"
echo "last_release=$LAST_RELEASE_TAG" >> $GITHUB_OUTPUT
- name: Set up Python
if: ${{ steps.release.outputs.release_created }}
uses: actions/setup-python@v5.2.0
with:
python-version: 3.x
- name: Install Poetry
if: ${{ steps.release.outputs.release_created }}
run: |
pip install poetry
poetry config virtualenvs.create false # Skip creating a virtual environment
env:
POETRY_HOME: ${{ github.workspace }}/.poetry
- name: Install project dependencies
if: ${{ steps.release.outputs.release_created }}
run: poetry install
env:
POETRY_HOME: ${{ github.workspace }}/.poetry
- name: Build package
if: ${{ steps.release.outputs.release_created }}
run: poetry build
env:
POETRY_HOME: ${{ github.workspace }}/.poetry
- name: Append custom release notes
if: ${{ steps.release.outputs.release_created }}
run: |
release_id=$(gh api \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/releases/tags/${{ steps.release.outputs.tag_name }} \
--jq .id)
# Fetch existing release body
existing_body=$(gh api /repos/${{ github.repository }}/releases/$release_id --jq .body)
# Create temporary file for new body
tmpfile=$(mktemp)
# Write combined content into the file
{
echo "$existing_body"
echo
echo "Install as package using:"
echo '```bash'
echo "pip install git+https://github.com/bensteUEM/ChurchToolsAPI.git@${{ steps.release.outputs.tag_name }}#egg=churchtools-api"
echo '```'
echo "**Full Changelog**: https://github.com/bensteUEM/ChurchToolsAPI/compare/${{ steps.get_last_release.outputs.last_release }}...${{ steps.release.outputs.tag_name }}"
} > "$tmpfile"
# Update the release body using the file
gh api \
-X PATCH \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/releases/$release_id \
-F body="$(cat "$tmpfile")"
- name: Upload Release Artifact
if: ${{ steps.release.outputs.release_created }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload ${{ steps.release.outputs.tag_name }} dist/*