Update README.md #61
This file contains hidden or 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: Bump version, publish to PyPI, tag, and deploy docs | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
bump_version: | |
name: Bump Version, Publish to PyPI, tag, and deploy docs | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_PAT }} # Use the PAT for push permissions | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
pip install tomlkit | |
pipx install poetry | |
- name: Determine version part to update | |
run: | | |
# Default to patch | |
VERSION_TYPE="patch" | |
MESSAGE=$(git log -1 --pretty=%B) | |
# Check for version bump keywords | |
if echo "$MESSAGE" | grep -qi '\[major\]'; then | |
VERSION_TYPE="major" | |
elif echo "$MESSAGE" | grep -qi '\[minor\]'; then | |
VERSION_TYPE="minor" | |
fi | |
echo "Determined VERSION_TYPE=$VERSION_TYPE" | |
echo "VERSION_TYPE=$VERSION_TYPE" >> $GITHUB_ENV | |
- name: Bump version | |
run: python bump_version.py $VERSION_TYPE | |
- name: Commit version bump | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add pyproject.toml | |
git add boto3_refresh_session/__init__.py | |
git commit -m "bump $VERSION_TYPE version [skip ci]" # <--- Prevents infinite loop | |
git push origin main # Push only the version bump commit | |
- name: Fetch latest commit after push | |
run: | | |
git fetch origin main | |
git reset --hard origin/main | |
- name: Create tag | |
run: | | |
VERSION=$(grep '^version' pyproject.toml | awk -F'"' '{print $2}') | |
git tag "$VERSION" | |
git push origin "$VERSION" | |
- name: Build wheel and publish to PyPI | |
env: | |
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }} | |
run: | | |
poetry install --no-interaction --all-groups | |
poetry build | |
poetry publish --no-interaction | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
virtualenvs-path: .venv | |
installer-parallel: true | |
- name: Cache Poetry dependencies | |
id: cached-poetry-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: .venv | |
key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock', '**/pyproject.toml') }} | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --no-root --all-groups | |
- name: Install project | |
run: poetry install --no-interaction --all-groups | |
- name: Build Documentation | |
run: | | |
source .venv/bin/activate | |
cd doc/ && make clean && cd .. | |
sphinx-build doc _build | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
publish_branch: gh-pages | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: _build/ | |
force_orphan: true |