Skip to content

Commit bfc1b1c

Browse files
committed
Update release.yml
1 parent f167315 commit bfc1b1c

File tree

1 file changed

+54
-20
lines changed

1 file changed

+54
-20
lines changed

.github/workflows/release.yml

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,42 +47,76 @@ jobs:
4747
run: |
4848
twine upload dist/*
4949
50+
- name: Extract changelog section
51+
id: changelog
52+
run: |
53+
VERSION=${GITHUB_REF_NAME#v}
54+
55+
# Extract changelog section for this version
56+
if [ -f CHANGELOG.md ]; then
57+
# Extract the section between [VERSION] and the next [VERSION] or end of file
58+
CHANGELOG_SECTION=$(awk "/^## \[$VERSION\]/{flag=1; next} /^## \[/{flag=0} flag" CHANGELOG.md)
59+
60+
if [ -n "$CHANGELOG_SECTION" ]; then
61+
echo "Found changelog section for version $VERSION"
62+
# Use a delimiter to handle multiline output properly
63+
echo "changelog_content<<EOF" >> $GITHUB_OUTPUT
64+
echo "$CHANGELOG_SECTION" >> $GITHUB_OUTPUT
65+
echo "EOF" >> $GITHUB_OUTPUT
66+
echo "has_changelog=true" >> $GITHUB_OUTPUT
67+
else
68+
echo "No changelog section found for version $VERSION"
69+
echo "has_changelog=false" >> $GITHUB_OUTPUT
70+
echo "changelog_content=See commit history for changes." >> $GITHUB_OUTPUT
71+
fi
72+
else
73+
echo "No CHANGELOG.md found"
74+
echo "has_changelog=false" >> $GITHUB_OUTPUT
75+
echo "changelog_content=See commit history for changes." >> $GITHUB_OUTPUT
76+
fi
77+
78+
- name: Get previous tag for comparison
79+
id: previous_tag
80+
run: |
81+
# Get the previous tag for comparison (handle case where there's no previous tag)
82+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 ${{ github.ref_name }}^ 2>/dev/null || echo "")
83+
if [ -n "$PREVIOUS_TAG" ]; then
84+
echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
85+
echo "Previous tag: $PREVIOUS_TAG"
86+
else
87+
echo "previous_tag=" >> $GITHUB_OUTPUT
88+
echo "No previous tag found (this might be the first release)"
89+
fi
90+
5091
- name: Create GitHub Release
51-
uses: actions/create-release@v1
52-
env:
53-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
uses: softprops/action-gh-release@v1
5493
with:
5594
tag_name: ${{ github.ref_name }}
56-
release_name: Release ${{ github.ref_name }}
95+
name: Release ${{ github.ref_name }}
5796
body: |
5897
## Changes in ${{ github.ref_name }}
5998
60-
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) for details.
99+
${{ steps.changelog.outputs.changelog_content }}
61100
62101
## Installation
63102
64103
```bash
65104
pip install ethopy-analysis==${{ github.ref_name }}
66105
```
67106
68-
## What's Changed
107+
## Links
69108
70-
- Check the commit history and pull requests for detailed changes
71-
- Full documentation available at the project homepage
109+
- 📚 [Documentation](https://ef-lab.github.io/ethopy_analysis)
110+
- 🐛 [Report Issues](https://github.com/ef-lab/ethopy_analysis/issues)
111+
- 📋 [Full Changelog](https://github.com/ef-lab/ethopy_analysis/blob/main/CHANGELOG.md)
72112
73-
**Full Changelog**: https://github.com/${{ github.repository }}/compare/v0.1.0...${{ github.ref_name }}
113+
${{ steps.previous_tag.outputs.previous_tag && format('**Comparison**: https://github.com/{0}/compare/{1}...{2}', github.repository, steps.previous_tag.outputs.previous_tag, github.ref_name) || '**First Release** 🎉' }}
74114
draft: false
75115
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
76-
77-
- name: Upload Release Assets
78-
uses: actions/upload-release-asset@v1
79-
env:
80-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81-
with:
82-
upload_url: ${{ steps.create_release.outputs.upload_url }}
83-
asset_path: ./dist/ethopy_analysis-${{ github.ref_name }}.tar.gz
84-
asset_name: ethopy_analysis-${{ github.ref_name }}.tar.gz
85-
asset_content_type: application/gzip
116+
files: |
117+
dist/*.tar.gz
118+
dist/*.whl
119+
generate_release_notes: true
86120

87121
test-install:
88122
needs: build-and-publish
@@ -105,4 +139,4 @@ jobs:
105139
- name: Test CLI
106140
run: |
107141
ethopy-analysis --help
108-
ethopy-analysis --version
142+
ethopy-analysis --version

0 commit comments

Comments
 (0)