Skip to content

Release

Release #3

Workflow file for this run

name: Release
on:
workflow_dispatch:
jobs:
build-package:
name: Build package
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- id: check_ref
run: echo "::set-output name=match::$(echo '${{ github.ref }}' | grep -Pq '^refs/tags/v\d+\.\d+\.\d+$' && echo true || echo false)"
shell: bash
- name: Check if tag is valid
if: steps.check_ref.outputs.match != 'true'
run: exit 1
- name: Checkout repository contents
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install poetry
run: |
pip install poetry
poetry install
- name: Build package
run: |
poetry build
- name: Cache built package artifacts
uses: actions/upload-artifact@v4
with:
name: package
path: |
dist/*
github-release:
name: Create GitHub release
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs:
- build-package
steps:
- uses: actions/checkout@v4
- name: Generate changelog
run: |
cat > CHANGELOG.md <<EOT
# CHANGELOG
**Release**: dt-cli (${GITHUB_REF#refs/tags/})
# Changes
EOT
git log --format=format:"%ad: %s" --date=short >> CHANGELOG.md
- name: Download cached built package
uses: actions/download-artifact@v4
with:
name: package
path: dist
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
files: |
dist/*
LICENSE
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-to-pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs:
- build-package
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install poetry
run: |
pip install poetry
poetry install
- name: Download cached built package
uses: actions/download-artifact@v4
with:
name: package
path: dist
- name: Publish to PyPI
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
poetry publish --username __token__ --password $PYPI_TOKEN