fix: Make sure pdf_to_image closes the pdf file #5
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: build-and-publish | |
| on: | |
| push: | |
| branches: | |
| - "master" | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@master | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: '3.x' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install uv | |
| - name: Build | |
| run: | | |
| uv build | |
| pip install dist/*.whl | |
| - name: check-version | |
| id: check-version | |
| run: | | |
| version=$(pip show pdf-helper | grep '^Version: ' | cut -d ' ' -f 2) | |
| echo "PACKAGE_VERSION=$version" >> $GITHUB_ENV | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| # Alpha check | |
| if echo "$version" | grep -qP '\d+\.\d+\.\d+a\d+'; then | |
| echo "is_alpha=$version" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_alpha=" >> $GITHUB_OUTPUT | |
| fi | |
| # Version-changed check | |
| if git tag --list | grep -qF "$version"; then | |
| echo "version_changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "version_changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: dist | |
| path: dist/ | |
| outputs: | |
| version: ${{ steps.check-version.outputs.version }} | |
| is_alpha: ${{ steps.check-version.outputs.is_alpha }} | |
| version_changed: ${{ steps.check-version.outputs.version_changed }} | |
| release: | |
| name: Auto Release | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: ${{ needs.build.outputs.is_alpha == '' && needs.build.outputs.version_changed == 'true' }} | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - uses: "marvinpinto/action-automatic-releases@latest" | |
| with: | |
| repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
| automatic_release_tag: "${{ needs.build.outputs.version }}" | |
| title: "v${{ needs.build.outputs.version }}" | |
| files: | | |
| dist/* | |
| publish: | |
| name: Publish to PyPI | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: ${{ needs.build.outputs.is_alpha == '' && needs.build.outputs.version_changed == 'true' }} | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Publish | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} |