Skip to content

MeasurementLink Support for Python v1.2.1-dev0 #35

MeasurementLink Support for Python v1.2.1-dev0

MeasurementLink Support for Python v1.2.1-dev0 #35

Workflow file for this run

name: Update docs and Publish NIMS
on:
release:
types: [published]
concurrency: publish_to_pypi
env:
# Versions are also listed in PR.yml
POETRY_VERSION: 1.2.2
PYTHON_VERSION: 3.9
jobs:
build:
name: Update API reference docs and Publish NIMS Package to PyPI
runs-on : ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: Gr1N/setup-poetry@v8
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: Check for lock changes
run: poetry lock --check
- uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Setup NIMS
run: poetry install
- name: Setup NIMG
run: poetry install
working-directory: ./ni_measurementlink_generator
- name: Lint NIMS, NIMG, and examples
run: poetry run ni-python-styleguide lint
# If the tag is 0.1.0, this will set the version of NIMS package to 0.1.0
- name: Store version from Tag
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Update NIMS package version based on tag name.
run: |
poetry version ${{ steps.vars.outputs.tag }}
- name: Update NIMG package version based on tag name.
run: |
poetry version ${{ steps.vars.outputs.tag }}
working-directory: ./ni_measurementlink_generator
- name: Setup NIMS with docs
run: poetry install --with docs
- name: Update API Reference Documents(Generated using Sphinx)
run: |
rm -rf docs
mkdir -p docs
touch docs/.nojekyll
poetry run sphinx-build _docs_source docs -b html
- name: Commit file changes.
if: ${{ startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/') }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Promote NIMS package version and update Sphinx generated files in _docs" -a
- name: Push changes to the appropriate branch
if: ${{ startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/') }}
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.ADMIN_PAT }}
branch: ${{ github.event.release.target_commitish }}
unprotect_reviews: true
# To Test the Publish use : poetry publish --build --username __token__ --password ${{ secrets.TEST_PYPI_TOKEN }} -r test-pypi
- name: Build NIMS Python package and publish to PyPI
if: ${{ startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/') }}
run: |
poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN }}
- name: Build NIMG Python package and publish to PyPI
if: ${{ startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/') }}
run: |
poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN }}
working-directory: ./ni_measurementlink_generator
- name: Create archives of the examples
env:
EXAMPLE_ARCHIVE: measurementlink-python-examples-${{ steps.vars.outputs.tag }}
run: |
# Use --prefix for the tarball but not the zip file. Windows zip tools often create a directory automatically.
git archive -o dist/${EXAMPLE_ARCHIVE}.zip ${GITHUB_REF}:examples/
git archive -o dist/${EXAMPLE_ARCHIVE}.tar.gz --prefix ${EXAMPLE_ARCHIVE}/ ${GITHUB_REF}:examples/
- name: Upload release assets
if: ${{ startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/') }}
uses: ncipollo/release-action@v1
with:
artifacts: "dist/measurementlink-python-examples-*"
allowUpdates: true
omitBodyDuringUpdate: true
omitDraftDuringUpdate: true
omitNameDuringUpdate: true
omitPrereleaseDuringUpdate: true
updateOnlyUnreleased: false
- uses: actions/upload-artifact@v3
with:
name: NIMS Artifacts
path: dist/ # path/to/artifact