Merge pull request #31 from tawanda-kembo/fix/adds-pygments-dependency #31
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: Tag, Release, and Publish | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
tag-and-release: | |
runs-on: ubuntu-latest | |
outputs: | |
new_version: ${{ steps.bump_version.outputs.NEW_VERSION }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Git | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
- name: Bump version and push tag | |
id: bump_version | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
run: | | |
./bump_version.sh | |
echo "NEW_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT | |
- name: Generate Release Notes | |
id: generate_notes | |
run: | | |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 --always HEAD^) | |
NOTES=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"* %s" --reverse) | |
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT | |
echo "$NOTES" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Update CHANGELOG.md | |
run: | | |
echo "# Changelog" > CHANGELOG.md | |
echo "" >> CHANGELOG.md | |
echo "## ${{ steps.bump_version.outputs.NEW_VERSION }}" >> CHANGELOG.md | |
echo "" >> CHANGELOG.md | |
echo "${{ steps.generate_notes.outputs.RELEASE_NOTES }}" >> CHANGELOG.md | |
echo "" >> CHANGELOG.md | |
git add CHANGELOG.md | |
git commit -m "Update CHANGELOG.md for ${{ steps.bump_version.outputs.NEW_VERSION }}" | |
git push | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ steps.bump_version.outputs.NEW_VERSION }} | |
name: Release ${{ steps.bump_version.outputs.NEW_VERSION }} | |
body: ${{ steps.generate_notes.outputs.RELEASE_NOTES }} | |
draft: false | |
prerelease: false | |
token: ${{ secrets.GITHUB_TOKEN }} | |
publish-to-pypi: | |
needs: tag-and-release | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build package | |
env: | |
PACKAGE_VERSION: ${{ needs.tag-and-release.outputs.new_version }} | |
run: python -m build | |
- name: Publish package | |
uses: pypa/[email protected] |