feat: fix timestamps #1
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 Package to PyPI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install setuptools wheel twine build | |
| - name: Check if version changed | |
| id: check_version | |
| run: | | |
| git fetch origin main | |
| PREV_VERSION=$(git show origin/main:logdash/__init__.py | grep -oP "__version__\s*=\s*['\"](\K[^'\"]+)") | |
| CURRENT_VERSION=$(grep -oP "__version__\s*=\s*['\"](\K[^'\"]+)" logdash/__init__.py) | |
| echo "Previous version: $PREV_VERSION" | |
| echo "Current version: $CURRENT_VERSION" | |
| if [ "$PREV_VERSION" != "$CURRENT_VERSION" ]; then | |
| echo "version_changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "version_changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build package | |
| if: steps.check_version.outputs.version_changed == 'true' | |
| run: python -m build | |
| - name: Publish package | |
| if: steps.check_version.outputs.version_changed == 'true' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} |