-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (54 loc) · 1.94 KB
/
auto-release.yaml
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
name: Create Release on Version Change
on:
push:
paths:
- 'setup.py'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Get version from setup.py
id: get_version
run: |
version=$(python setup.py --version)
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Get latest release
id: get_latest_release
run: |
latest_release=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
echo "LATEST_RELEASE=${latest_release}" >> $GITHUB_ENV
- name: Compare versions
id: compare
run: |
if [ "${VERSION}" != "${LATEST_RELEASE}" ]; then
echo "Version has changed"
echo "SHOULD_RELEASE=true" >> $GITHUB_ENV
else
echo "Version has not changed"
echo "SHOULD_RELEASE=false" >> $GITHUB_ENV
- name: Create release
if: env.SHOULD_RELEASE == 'true'
id: create_release
run: |
new_tag="v${VERSION}"
previous_tag="${LATEST_RELEASE}"
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "'"${new_tag}"'",
"target_commitish": "'"${{ github.sha }}"'",
"name": "'"${{ github.event.head_commit.message }}"'",
"body": "**Full Changelog**: https://github.com/lzgirlcat/koleo-cli/compare/${previous_tag}..${new_tag}",
"draft": false,
"prerelease": false
}' https://api.github.com/repos/${{ github.repository }}/releases