Release new version #5
Workflow file for this run
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: Publish Python Package | |
on: | |
push: | |
tags: | |
- "*.*.*" # Trigger when a tag with format X.X.X(-xxx0) is pushed | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' # Set your Python version | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build twine # For packaging and publishing | |
- name: Build package | |
run: python -m build | |
- name: Publish package to PyPI | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
python -m twine upload dist/* | |
- name: Determine if this is a prerelease | |
id: check_prerelease | |
run: | | |
TAG=${{ github.ref_name }} | |
if [[ "$TAG" =~ -[a-zA-Z]+[0-9]*$ ]]; then | |
echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT | |
else | |
echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Extract latest release notes | |
id: get_release_notes | |
run: | | |
TAG=${{ github.ref_name }} # Get the current tag (e.g., 1.2.0) | |
sed -n "/## \[${TAG}\]/,/## \[/p" CHANGELOG.md | sed '$d' | tail -n +3 > release_notes.txt | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref_name }} | |
release_name: Release ${{ github.ref_name }} | |
body_path: release_notes.txt # This is where the file is referenced | |
draft: false | |
prerelease: ${{ steps.check_prerelease.outputs.IS_PRERELEASE }} | |
notify: | |
name: "Notify socials" | |
needs: [publish] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Discord notification | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
uses: Ilshidur/action-discord@master | |
with: | |
args: "**nanosaur-cli ${{ github.ref_name }}** has been deployed!\nTo install follow `pip3 install nanosaur==${{ github.ref_name }}`" |