Jonxslays/wom.py

View on GitHub
.github/workflows/release.yml

Summary

Maintainability
Test Coverage
name: Publish release

on:
  release:
    types: [published]

permissions:
  contents: write

jobs:
  pypi:
    name: Pypi release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Run pre-release script
        id: prerelease
        run: ./scripts/pre-release.sh

      - name: Build and publish
        id: publish
        uses: JRubics/poetry-publish@v1.16
        if: steps.prerelease.conclusion == 'success'
        with:
          pypi_token: ${{ secrets.PYPI_TOKEN }}
          ignore_dev_requirements: "yes"

      - name: Send release webhook
        if: steps.publish.conclusion == 'success'
        run: |
          VERSION=$(sed -rn 's/__version__: Final\[str\] = "(.*)"/\1/p' wom/__init__.py);

          curl -X POST ${{ secrets.WOM_DISCORD_WEBHOOK_URL }} \
            -H "Content-Type: application/json" \
            -d '{
              "username": "Automated Old Man",
              "avatar_url": "https://jonxslays.github.io/wom.py/dev/wom-logo.png",
              "embeds": [{
                "color": 3447003,
                "title": "wom.py v'$VERSION' has released to PyPI",
                "description": "**Upgrade with**:\n```pip install -U wom.py=='$VERSION'```\n- [Changelog](https://github.com/Jonxslays/wom.py/blob/master/CHANGELOG.md)\n- [Repository](https://github.com/Jonxslays/wom.py)\n- [Python Package Index](https://pypi.org/project/wom-py)"
              }]
            }'

  docs:
    name: Stable docs release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup python 3.10
        uses: actions/setup-python@v4
        with:
          python-version: "3.10"

      - name: Install poetry
        uses: Gr1N/setup-poetry@v8

      - name: Install dependencies
        run: |
          pip install -U pip
          poetry install

      - name: Build and deploy
        run: |
          git config --global user.name "Jonxslays"
          git config --global user.email "51417989+Jonxslays@users.noreply.github.com"
          git fetch origin gh-pages --depth=1
          poetry run mike deploy --push --update-aliases $GITHUB_REF_NAME stable