fix removing venv after fetching previous version. #4
Workflow file for this run
This file contains hidden or 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: publish | |
on: | |
push: | |
branches: | |
- '**' | |
# workflow_run: | |
# workflows: [ci] | |
# branches: [feature/deploys] | |
# types: [completed] | |
jobs: | |
publish: | |
# if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout code | |
uses: actions/checkout@v4 | |
- name: set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
cache: 'pip' | |
- name: upgrade pip | |
run: python -m pip install --upgrade pip | |
- name: install dependencies | |
run: pip install -r requirements.txt -e . | |
- name: build package | |
run: python3 -m build | |
- name: check version | |
id: check_version | |
run: | | |
package_name=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['name'])") | |
python -m venv .pyenv | |
source .pyenv/bin/activate | |
pip install --upgrade pip | |
pip install "$package_name" | |
previous_version=$(pip show "$package_name" | grep Version | awk '{print $2}' || echo "0.0.0") | |
deactivate && rm -rf .pyenv | |
current_version=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") | |
if dpkg --compare-versions "$current_version" gt "$previous_version"; then | |
echo -e "[+] version upgraded from [$previous_version] to [$current_version]" | |
echo -e "[+] publishing package to pypi" | |
echo "publish=true" >> $GITHUB_OUTPUT | |
else | |
echo -e "[+] version not upgraded. previous[$previous_version]; current[$current_version]." | |
echo -e "[+] skipping publishing package to pypi" | |
echo "publish=false" >> $GITHUB_OUTPUT | |
fi | |
# - name: publish package to pypi | |
# if: steps.check_version.outputs.publish == 'true' | |
# env: | |
# TWINE_USERNAME: __token__ | |
# TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
# run: twine upload dist/* |