Merge pull request #480 from dvonthenen/close-socket-on-server-termin… #15
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: Generate PyDocs on Release | |
on: | |
push: | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+" | |
- "v[0-9]+.[0-9]+.[0-9]+-doc.[0-9]+" | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code from main branch | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
repository: ${{ github.repository }} | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pdoc | |
pip install --upgrade py2app | |
pip install python-dotenv | |
pip install -r requirements.txt | |
- name: Get the current tag name | |
run: echo "TAG_NAME=${GITHUB_REF##*/}" >> "$GITHUB_ENV" | |
# New Step: Extracting Major Version Number | |
- name: Set the current major version | |
run: echo "MAJOR_VERSION=$(echo "$TAG_NAME" | cut -d '.' -f 1)" >> "$GITHUB_ENV" # This extracts the major version assuming a 'vX.Y.Z' format | |
- name: Checkout the gh-pages branch | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
path: gh-pages | |
- name: Generate Documentation for the current tag | |
run: | | |
ROOT_PATH="$(pwd)" # Moved this line up to ensure ROOT_PATH is set before its usage | |
rm -rf "$ROOT_PATH/gh-pages/docs/$MAJOR_VERSION" | |
mkdir -p "$ROOT_PATH/gh-pages/docs/$MAJOR_VERSION" # Note: Changed to use MAJOR_VERSION to create/update the major version folder | |
cd "$ROOT_PATH/deepgram" | |
pdoc "$ROOT_PATH/deepgram" -o "$ROOT_PATH/gh-pages/docs/$MAJOR_VERSION" # Documentation is generated/updated in the major version folder | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./gh-pages | |
publish_branch: gh-pages | |
keep_files: true | |
- name: Print the GitHub Pages URL for the current tag | |
run: | | |
echo "Documentation URL for $TAG_NAME: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/docs/$MAJOR_VERSION/index.html" | |
- name: Wait for GitHub Pages to become ready | |
run: sleep 60 | |
- name: Check documentation availability for the current tag | |
run: | | |
URL="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/docs/$MAJOR_VERSION/index.html" | |
HTTP_STATUS=$(curl -o /dev/null -s -w "%{http_code}\n" "$URL") | |
if [ "$HTTP_STATUS" != "200" ]; then | |
echo "Documentation for $TAG_NAME not available yet, actual HTTP status: $HTTP_STATUS" | |
exit 1 | |
else | |
echo "Documentation for $TAG_NAME is successfully published and available." | |
fi |