Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cd: add gihub based [dst-150] #26

Merged
merged 1 commit into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: CD

on:
release:
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build sphinx pydata_sphinx_theme

- name: Get new version number from tag
run: |
ref="${{github.ref}}"
prefix="refs/tags/v"
suffix="-test"
version=${ref#$prefix}
version=${version%$suffix}
echo "VERSION_NUMBER=$version" >> $GITHUB_ENV

- name: Replace package version number
run: |
filename="./datareservoirio/__init__.py"
search_pattern="__version__ = \"0.0.1\""
replacement_text="__version__ = \"$VERSION_NUMBER\""
sed -i "s/$search_pattern/$replacement_text/" "$filename"

- name: Build package
run: python -m build --sdist --wheel --outdir ./dist

- name: Build documentation
run: |
pip install .
sphinx-build -b html ./docs ./build/html

- name: Publish package to TestPyPi
if: ${{ startswith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-test') }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TEST_API_KEY }}
repository_url: https://test.pypi.org/legacy/

- name: Publish package to PyPi
if: ${{ startswith(github.ref, 'refs/tags/v') && !endsWith(github.ref, '-test') }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PROD_API_KEY }}

- name: Upload documentation to TEST blob storage
if: ${{ startswith(github.ref, 'refs/tags/v') && endsWith(github.ref, '-test') }}
uses: azure/CLI@v1
env:
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.FOURINSIGHTTEST_DOC_BLOB_CONNSTR }}
with:
inlineScript: |
az storage blob delete-batch -s "\$web" --pattern "datareservoirio/python/docs/latest/*"
az storage blob upload-batch -d "\$web" -s ./build/html --destination-path "datareservoirio/python/docs/latest"
az storage blob upload-batch -d "\$web" -s ./build/html --destination-path "datareservoirio/python/docs/v$VERSION_NUMBER"

- name: Upload documentation to PROD blob storage
if: ${{ startswith(github.ref, 'refs/tags/v') && !endsWith(github.ref, '-test') }}
uses: azure/CLI@v1
env:
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.FOURINSIGHTPROD_DOC_BLOB_CONNSTR }}
with:
inlineScript: |
az storage blob delete-batch -s "\$web" --pattern "datareservoirio/python/docs/latest/*"
az storage blob upload-batch -d "\$web" -s ./build/html --destination-path "datareservoirio/python/docs/latest"
az storage blob upload-batch -d "\$web" -s ./build/html --destination-path "datareservoirio/python/docs/v$VERSION_NUMBER"
29 changes: 0 additions & 29 deletions .github/workflows/deploy.yml

This file was deleted.