-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (52 loc) · 1.81 KB
/
release.yml
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
name: Create Release on Push
on:
push:
branches:
- main
paths:
- 'setup.py'
jobs:
# ... (previous jobs)
release:
needs: check-version-changed
if: needs.check-version-changed.outputs.version_changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Ensure all tags are fetched
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Extract Version from setup.py
id: get_version
run: |
echo "VERSION=$(python setup.py --version)" >> $GITHUB_OUTPUT
- name: Get last tag
id: get_last_tag
run: |
echo "LAST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
- name: Create and Push Tag
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
NEW_TAG="v${{ steps.get_version.outputs.VERSION }}"
git tag $NEW_TAG
git push origin $NEW_TAG
- name: Generate Release Notes
id: generate_release_notes
run: |
NEW_TAG="v${{ steps.get_version.outputs.VERSION }}"
LAST_TAG=${{ steps.get_last_tag.outputs.LAST_TAG }}
RELEASE_NOTES=$(git log $LAST_TAG...$NEW_TAG --pretty=format:"- %s" --reverse)
echo "RELEASE_NOTES=$RELEASE_NOTES" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: "neuralnetlib ${{ steps.get_version.outputs.VERSION }}"
tag_name: ${{ steps.get_version.outputs.VERSION }}
body: ${{ steps.generate_release_notes.outputs.RELEASE_NOTES }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}