Skip to content

Merge pull request #188 from ORNL/dev #87

Merge pull request #188 from ORNL/dev

Merge pull request #188 from ORNL/dev #87

name: Release and Publish
on:
push: # It has to be push, otherwise error happens in code below.
branches: [ "main" ]
# branches: [ "main", "dev" ] # use this only to test the CI. If testing this CI, consider commenting out the automatic version updates and manually adjust the patch version.
#branches: [ "disabled" ]
jobs:
build:
name: Create Release and Publish
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Update version.py
run: |
export PYTHONPATH=$PYTHONPATH:flowcept
python .github/workflows/version_bumper.py
- name: Commit new version
run: |
git config --global user.name 'Flowcept CI Bot'
git config --global user.email '[email protected]'
git branch
git add src/flowcept/version.py
git commit -m "Flowcept CI Bot: bumping master version"
git push --force
- name: Get Latest PR and Create Release
run: |
export CURRENT_VERSION=`python -c "f = open('src/flowcept/version.py'); exec(f.read()); print(locals()['__version__']); f.close()"`
echo $CURRENT_VERSION
REPOSITORY=${{ github.repository }}
ACCESS_TOKEN=${{ secrets.GITHUB_TOKEN }}
TARGET=${{ steps.branch-name.outputs.current_branch }}
echo "REPOSITORY=$REPOSITORY"
echo "TARGET=$TARGET"
echo "CURRENT_VERSION=${CURRENT_VERSION}"
echo "Get latest PR"
LATEST_PR_JSON=`curl -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
"https://api.github.com/repos/${REPOSITORY}/pulls?state=all&per_page=1&sort=created&base=main&direction=desc"`
LATEST_PR=`echo $LATEST_PR_JSON | python -c "import json, sys; data = json.load(sys.stdin); print(data[0]['html_url'])"`
echo "Latest PR: ${LATEST_PR}"
echo "Now Release the version"
curl --data "{\"tag_name\": \"v${CURRENT_VERSION}\",
\"target_commitish\": \"${TARGET}\",
\"name\": \"v${CURRENT_VERSION}\",
\"body\": \"Release of version ${CURRENT_VERSION}.\nRun \`pip install flowcept==${CURRENT_VERSION}\` to install this version.\n\nFor more details about the latest changes in this version, see the latest Pull Request's commits to the main branch: ${LATEST_PR}.\",
\"make_latest\": \"true\",
\"draft\": false,
\"prerelease\": false}" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
https://api.github.com/repos/${REPOSITORY}/releases
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
verbose: true
- name: Publish distribution to PyPI
#if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
- name: Wait pypi do its thing
run: sleep 120
- name: Test pip install
run: pip install flowcept
- name: Print installed version
run: pip list | grep flowcept
- name: Test pip install one adapter
run: pip install flowcept[dask]
- name: Test pip install multiple adapters
run: pip install flowcept[mlflow,tensorboard]
- name: Install our dependencies
run: pip install flowcept[all]
- name: Install ml_dev dependencies
run: pip install flowcept[ml_dev]
- name: Pip list
run: pip list
- name: Start up services
run: make services
- name: Test with pytest
run: pytest
- name: Test notebooks
run: |
# export FLOWCEPT_SETTINGS_PATH=~/.flowcept/settings.yaml
python src/flowcept/flowcept_webserver/app.py &
sleep 3
pytest --nbmake "notebooks/" --nbmake-timeout=600 --ignore=notebooks/dask_from_CLI.ipynb
- name: Stop services
run: make services-stop
- name: Clean up
run: |
make clean
find /home/runner/runners/ -type f -name "*.log" -exec sh -c 'echo {}; >"{}"' \; || true
docker image prune -a -f