diff --git a/.github/workflows/build_packages.yaml b/.github/workflows/build_packages.yaml index 48f280270..b5e89fe65 100644 --- a/.github/workflows/build_packages.yaml +++ b/.github/workflows/build_packages.yaml @@ -25,229 +25,22 @@ defaults: run: shell: bash -# Some considerations: https://github.com/orgs/community/discussions/38443 jobs: - # TODO sync sourcebuild patches with pdfium-binaries on before release? - # TODO(201): schedule test_setup and test_sourcebuild separately? - - test_setup: - if: ${{ inputs.pre_test }} - uses: ./.github/workflows/test_setup.yaml - - test_sourcebuild: - if: ${{ inputs.pre_test }} - uses: ./.github/workflows/test_sourcebuild.yaml - - build: - runs-on: ${{ inputs.runner }} - outputs: - new_version: ${{ steps.get_version.outputs.new_version }} - - steps: - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ inputs.py_version }} - - - name: Check out repository - uses: actions/checkout@v4 - with: - repository: ${{ github.repository }} - fetch-depth: 0 - - - name: Install/update dependencies - run: python3 -m pip install -U -r req/default.txt -r req/utilities.txt - - # NOTE autorelease sets a tag, but it's just temporary for informational purpose and does not match the actually published tag - # We can't push the tag at this stage because we don't know the outcome of the following jobs yet - # -> TODO avoid tmp tag - - name: Run autorelease script - run: | - git config user.email "geisserml@gmail.com" - git config user.name "geisserml" - git reset --hard HEAD - python3 setupsrc/pypdfium2_setup/autorelease.py --register - git checkout autorelease_tmp - - - name: Get new version - id: get_version - run: echo "new_version=$(git describe --abbrev=0)" >> $GITHUB_OUTPUT - - - name: Install pypdfium2 - run: python3 -m pip install --no-build-isolation -e . - - - name: Run test suite - run: ./run test - - - name: Run packaging script - run: ./run packaging - - - name: Upload release notes - uses: actions/upload-artifact@v3 - with: - name: release_notes - path: RELEASE.md - - - name: Upload packages - uses: actions/upload-artifact@v3 - with: - name: packages - path: dist/* - - # tag deliberately not pushed (see above) - - name: Push autorelease_tmp branch - run: git push -u origin autorelease_tmp - - - test: - if: ${{ inputs.test }} - needs: build - - strategy: - fail-fast: false - matrix: - os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] - py: ['3.7', '3.8', '3.9', '3.10', '3.11'] - include: - - os: ubuntu-latest - wheel: dist/*manylinux_*_x86_64*.whl - - os: macos-latest - wheel: dist/*macosx_*_x86_64*.whl - - os: windows-latest - wheel: dist/*win_amd64.whl - - runs-on: ${{ matrix.os }} - - steps: - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.py }} - - - name: Check out repository - uses: actions/checkout@v4 - with: - repository: ${{ github.repository }} - ref: autorelease_tmp - - - name: Download packages - uses: actions/download-artifact@v3 - with: - name: packages - path: dist/ - - - name: Install dependencies - run: | - python3 -m pip install -U pip setuptools - python3 -m pip install -U pytest pillow numpy wheel - - - name: Install pypdfium2 from artifact - run: python3 -m pip install ${{ matrix.wheel }} - - - name: Run Test Suite - run: ./run test - - - publish: + test_trigger: - needs: [test_setup, test_sourcebuild, build, test] - if: ${{ inputs.publish && !cancelled() && !contains(needs.*.result, 'failure') }} - runs-on: ${{ inputs.runner }} - - # `environment: release` is mandatory for our PyPI/TestPyPI upload via "trusted publishing". - # (On PyPI config time, restricting the environment is optional, but strongly encouraged. Once installed on PyPI, it must be set in the workflow. This applies here.) - # https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment + # ... + runs-on: ubuntu-latest environment: release permissions: - # `id-token: write` is mandatory for PyPI/TestPyPI upload via "trusted publishing". id-token: write - # `contents: write` is required for the repository changes contents: write + # test permissions required to trigger workflow + actions: write steps: - - - name: Check out repository (deep) - uses: actions/checkout@v4 - with: - repository: ${{ github.repository }} - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ inputs.py_version }} - - - name: Download packages - uses: actions/download-artifact@v3 - with: - name: packages - path: dist/ - - - name: Download release notes - uses: actions/download-artifact@v3 - with: - name: release_notes - - - name: Apply and push repository changes - run: | - git config user.email "geisserml@gmail.com" - git config user.name "geisserml" - git checkout main - git merge origin/autorelease_tmp - git tag -a ${{ needs.build.outputs.new_version }} -m "Autorelease" - git push - git push --tags - git checkout stable - git reset --hard main - git push --force - git checkout main - - - name: Publish to GitHub - uses: ncipollo/release-action@v1 - with: - artifacts: 'dist/*' - bodyFile: 'RELEASE.md' - token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ needs.build.outputs.new_version }} - prerelease: ${{ contains(needs.build.outputs.new_version, 'b') }} - - # Upload to TestPyPI / PyPI via "trusted publishing". - # https://docs.pypi.org/trusted-publishers/adding-a-publisher/ - # https://docs.pypi.org/trusted-publishers/using-a-publisher/ - # https://github.com/pypa/gh-action-pypi-publish - - - name: Publish to TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ - packages-dir: dist/ # the default - - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages-dir: dist/ # the default - - name: Trigger GH Pages rebuild uses: benc-uk/workflow-dispatch@v1 with: - workflow: gh_pages.yaml # takes no inputs - - - cleanup: - needs: [build, test, publish] - if: always() - runs-on: ${{ inputs.runner }} - - steps: - - - name: Check out repository - uses: actions/checkout@v4 - with: - repository: ${{ github.repository }} - - - name: Remove temporary branch - run: git push origin --delete autorelease_tmp + workflow: gh_pages.yaml