remove rich tracebacks, add auto-release #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |