deploy #4713
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: deploy | |
on: | |
workflow_run: | |
workflows: [testing] | |
types: [completed] | |
jobs: | |
deploy-docs: | |
# only run if commit is a push to master and the testing finished | |
if: ${{ github.repository_owner == 'materialsproject' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && startsWith(github.event.workflow_run.head_branch, 'v0.') }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.workflow_run.head_branch }} | |
- name: Install pandoc | |
run: sudo apt-get install pandoc | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
cache: pip | |
cache-dependency-path: pyproject.toml | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install .[strict,docs] | |
- name: Build | |
run: sphinx-build docs docs_build | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | |
publish_dir: ./docs_build/ | |
deploy-pypi: | |
# only run if commit is a push to master, the testing finished, and tagged as version | |
if: github.repository_owner == 'materialsproject' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && startsWith(github.event.workflow_run.head_branch, 'v0.') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.workflow_run.head_branch }} | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.10" | |
- name: Build | |
run: | | |
pip install build | |
python -m build | |
- name: Publish | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_PASSWORD }} | |
deploy-github: | |
runs-on: ubuntu-latest | |
needs: | |
- deploy-pypi | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.workflow_run.head_branch }} | |
- name: Write release info | |
run: | | |
awk 'BEGIN {p = 0} {a = 0 }; /^\#\#\ v\d*.\d*.\d*./ { p += 1; a = 1}; p + a == 1 { print } ' CHANGELOG.md | sed -e '1,1d' | sed -e '/./,$!d' -e :a -e '/^\n*$/{$d;N;ba' -e '}' > release_info.txt | |
echo "" >> release_info.txt | |
awk '/CONTRIBUTOR SECTION/{f=1; c=0} f' CHANGELOG.md >> release_info.txt | |
- name: Release | |
uses: actions/create-release@v1 | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.event.workflow_run.head_branch }} | |
release_name: ${{ github.event.workflow_run.head_branch }} | |
body_path: release_info.txt | |
draft: false | |
prerelease: false |