| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
- # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
- name: Python package
- on:
- push:
- tags:
- - '*released'
- workflow_dispatch:
- jobs:
- update-version:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
- with:
- refs: master
- fetch-depth: 0
- - name: Set up Python
- uses: actions/setup-python@v5
- with:
- python-version: "3.10"
- - name: Update version.py
- run: |
- python update_version.py
- - name: Verify version.py
- run: |
- ls -l magic_pdf/libs/version.py
- cat magic_pdf/libs/version.py
- - name: Commit changes
- run: |
- git config --local user.email "moe@myhloli.com"
- git config --local user.name "myhloli"
- git add magic_pdf/libs/version.py
- if git diff-index --quiet HEAD; then
- echo "No changes to commit"
- else
- git commit -m "Update version.py with new version"
- fi
- id: commit_changes
- - name: Push changes
- if: steps.commit_changes.outcome == 'success'
- env:
- GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
- run: |
- git push origin HEAD:master
- # git remote set-url origin https://myhloli:${{ secrets.RELEASE_TOKEN }}@github.com/magicpdf/Magic-PDF.git
- # git checkout -b update-version-branch || git checkout update-version-branch
- # git push --set-upstream origin update-version-branch
- # id: push_changes
- # - name: Create Pull Request
- # if: steps.push_changes.outcome == 'success'
- # id: create_pull_request
- # uses: peter-evans/create-pull-request@v5
- # with:
- # token: ${{ secrets.RELEASE_TOKEN }}
- # commit-message: Update version.py with new version
- # branch: update-version-branch
- # title: 'Update version.py'
- # body: 'This PR updates the version.py file with the latest version.'
- # base: master
- # labels: 'automated PR'
- #
- # - name: Merge Pull Request
- # if: steps.create_pull_request.outputs.pull-request-number
- # uses: actions/github-script@v6
- # with:
- # github-token: ${{ secrets.RELEASE_TOKEN }}
- # script: |
- # const pullRequestNumber = parseInt('${{ steps.create_pull_request.outputs.pull-request-number }}');
- # await github.pulls.merge({
- # owner: context.repo.owner,
- # repo: context.repo.repo,
- # pull_number: pullRequestNumber,
- # merge_method: 'merge'
- # });
- build:
- needs: [ update-version ]
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- python-version: ["3.10"]
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- with:
- fetch-depth: 0
- - name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v5
- with:
- python-version: ${{ matrix.python-version }}
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- - name: Install wheel
- run: |
- python -m pip install wheel
- - name: Build wheel
- run: |
- python setup.py bdist_wheel
- - name: Upload artifact
- uses: actions/upload-artifact@v4
- with:
- name: wheel-file
- path: dist/*.whl
- retention-days: 30
- release:
- needs: [ build ]
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
- - name: Download artifact
- uses: actions/download-artifact@v4
- with:
- name: wheel-file
- path: dist
- - name: Create and Upload Release
- id: create_release
- uses: softprops/action-gh-release@4634c16e79c963813287e889244c50009e7f0981
- with:
- files: './dist/*.whl'
- env:
- GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
- # - name: Publish to PyPI
- # uses: pypa/gh-action-pypi-publish@release/v1
- # with:
- # user: __token__
- # password: ${{ secrets.PYPI_TOKEN }}
|