Release #2
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: Release | |
on: | |
workflow_run: | |
workflows: ["Run Tests"] | |
types: [completed] | |
branches: | |
- main | |
- dev | |
env: | |
AWS_REGION: eu-west-2 | |
AWS_OIDC_ROLE_ARN: arn:aws:iam::980416368045:role/GitHubAction-AssumeRoleWithAction | |
DOCS_UPLOAD_URL: s3://sachahu.com/docs/Github-Search-Engine | |
PROJECT_NAME : Github-Search-Engine | |
jobs: | |
release: | |
name: Release pushed tag | |
runs-on: ubuntu-22.04 | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up python | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "^3.11.0" | |
#---------------------------------------------- | |
# ----- install & configure poetry ----- | |
#---------------------------------------------- | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Python Semantic Release | |
uses: python-semantic-release/python-semantic-release@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Package build | |
run: | | |
poetry build | |
- name: Upload a Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: dist | |
path: ./dist | |
deploy: | |
runs-on: ubuntu-latest | |
needs: | |
- release | |
permissions: | |
id-token: write | |
environment: | |
name: pypi | |
url: https://pypi.org/p/${{ env.PROJECT_NAME }} | |
steps: | |
- name: Download a Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: dist | |
path: ./dist | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
build-release-docs: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up python | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "^3.11.0" | |
#---------------------------------------------- | |
# ----- install & configure poetry ----- | |
#---------------------------------------------- | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
#---------------------------------------------- | |
# install dependencies if cache does not exist | |
#---------------------------------------------- | |
- name: Install dependencies | |
run: poetry install --only documentation | |
- name: configure aws credentials | |
uses: aws-actions/[email protected] | |
with: | |
role-to-assume: ${{ env.AWS_OIDC_ROLE_ARN }} | |
role-session-name: GitHub_to_AWS_via_FederatedOIDC | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Build and Deploy docs | |
run: | | |
poetry run sphinx-build -M html docs/source/ docs/build | |
aws s3 sync docs/build/html ${{ env.DOCS_UPLOAD_URI }}/pages/v$(poetry version --short) --delete | |
aws s3 sync docs/build/html ${{ env.DOCS_UPLOAD_URI }}/latest --delete | |
rm -rf docs/build | |