Skip to content

CD

CD #27

Workflow file for this run

# This workflow will retreive version name from setup.py and build the according Docker Image, pypi package and documentation
name: CD
on:
workflow_run:
workflows: "CI" # Reference the test workflow
branches: main
types: completed # Trigger only after the test workflow is completed
jobs:
create_release:
name: Build and create release
runs-on: ubuntu-22.04
if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/main' }}
# Ensure it's on the 'main' branch and the test workflow was successful
environment: pypi
permissions: write-all
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build release distributions
run: |
# NOTE: put your own distribution build steps here.
python -m pip install build
python -m build
- name: Get the current version
id: extract_version
run: |
VERSION=$(python -c "import prescyent; print(prescyent.__version__)")
echo "VERSION=$VERSION" >> $GITHUB_ENV
# DOCKER
# Commented out as the tar of the docker image exceeds maximum disk space for the github ci runner
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# - name: Build Docker Image
# id: docker_build
# run: |
# docker build -t prescyent:latest -t prescyent:${{ env.VERSION }} .
# - name: Save Docker Image to tar
# run: |
# docker save prescyent:latest -o prescyent-${{ env.VERSION }}.tar
# CREATE RELEASE
- name: Create GitHub Release
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.VERSION }}
release_name: Release v${{ env.VERSION }}
body: |
Automatic release for version v${{ env.VERSION }}.
draft: false
prerelease: false
# - name: Upload Python Wheel to Release
# uses: actions/upload-release-asset@v1
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./dist/*.whl
# asset_name: prescyent-${{ env.VERSION }}.whl
# asset_content_type: application/octet-stream
# - name: Upload Python Source Distribution to Release
# uses: actions/upload-release-asset@v1
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./dist/*.tar.gz
# asset_name: prescyent-${{ env.VERSION }}.tar.gz
# asset_content_type: application/gzip
# - name: Upload Docker Image to Release
# uses: actions/upload-release-asset@v1
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ./prescyent-${{ env.VERSION }}.tar
# asset_name: prescyent-${{ env.VERSION }}.tar
# asset_content_type: application/x-tar
# Test the workflow with testpypi here: (update environment to testpypi)
# - name: Publish package distributions to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
pages:
# needs: create_release
name: Build doc and publish it as github page
runs-on: ubuntu-22.04
if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/main' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
pages: write
id-token: write
steps:
- id: deployment
uses: sphinx-notes/pages@v3