.github/workflows/cd.yml
########[CD PIPELINE FLOW]########
# Run ci_succeed: #
# | failure ~> stop. #
# | pass: #
# Run create_release: #
# | failure ~> stop. #
# | pass: #
# Run publish. #
##################################
# Requiered Github secrets: #
# - GITHUB_TOKEN #
# - PYPI_TOKEN #
##################################
name: CD
on:
push:
tags:
- "v*.*.*"
jobs:
ci_succeed:
name: Check CI Status
runs-on: ubuntu-latest
steps:
- uses: hadialqattan/relies-on@v1.0.0
with:
workflow: CI
create_release:
name: Create Release
needs: ci_succeed
runs-on: ubuntu-latest
steps:
- name: Get version from tag
id: tag_name
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
shell: bash
- name: Checkout code
uses: actions/checkout@v4
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
version: ${{ steps.tag_name.outputs.current_version }}
path: ./docs/CHANGELOG.md
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# This pulls from the "Get Changelog Entry" step above,
# referencing it's ID to get its outputs object.
tag_name: v${{ steps.changelog_reader.outputs.version }}
release_name: v${{ steps.changelog_reader.outputs.version }}
body: ${{ steps.changelog_reader.outputs.changes }}
prerelease: ${{ steps.changelog_reader.outputs.status == 'prereleased' }}
draft: ${{ steps.changelog_reader.outputs.status == 'unreleased' }}
publish:
name: Build & Publish
needs: [ci_succeed, create_release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.17
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}