Release #962
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: Release | |
| on: | |
| workflow_run: | |
| workflows: ["Run Tests"] | |
| types: | |
| - completed | |
| jobs: | |
| auto-merge: | |
| if: github.event.workflow_run.conclusion == 'success' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| mergeResult: ${{ steps.merge.outputs.mergeResult }} | |
| prLabels: ${{ steps.get_labels.outputs.labels }} | |
| permissions: | |
| pull-requests: write | |
| contents: write | |
| actions: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Get PR labels | |
| id: get_labels | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prs = context.payload.workflow_run.pull_requests; | |
| if (!prs || prs.length === 0) { | |
| core.info("Could not find any pull requests in the workflow run."); | |
| core.setOutput("labels", "[]"); | |
| return; | |
| } | |
| const prNumber = prs[0].number; | |
| core.info(`Found PR number: ${prNumber}`); | |
| const { data: pr } = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: prNumber, | |
| }); | |
| const labels = pr.labels.map(label => label.name); | |
| core.info(`Retrieved labels: ${labels}`); | |
| core.setOutput("labels", JSON.stringify(labels)); | |
| - name: Debug labels output | |
| run: | | |
| echo "Labels output: ${{ steps.get_labels.outputs.labels }}" | |
| - name: Auto merge if auto-merge-ok label exists | |
| id: merge | |
| if: contains(fromJson(steps.get_labels.outputs.labels || '[]'), 'auto-merge-ok') | |
| uses: pascalgn/[email protected] | |
| env: | |
| GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
| MERGE_LABELS: "auto-merge-ok" | |
| MERGE_METHOD: squash | |
| MERGE_DELETE_BRANCH: true | |
| tag-release: | |
| runs-on: ubuntu-latest | |
| needs: auto-merge | |
| if: ${{ needs.auto-merge.outputs.mergeResult == 'merged' && contains(fromJson(needs.auto-merge.outputs.prLabels || '[]'), 'release') }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.9' | |
| - name: Wait for apt-get lock | |
| run: | | |
| while sudo fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do | |
| echo "Waiting for apt lock release..." | |
| sleep 1 | |
| done | |
| - name: Install APT On Linux | |
| run: | | |
| sudo apt-get update -qq -y | |
| sudo apt-get install -qq -y libspatialindex-dev freeglut3-dev libsuitesparse-dev libblas-dev liblapack-dev | |
| sudo apt-get install -qq -y xvfb # for headless testing | |
| - name: Install package | |
| run: | | |
| python -m pip install --upgrade pip setuptools wheel | |
| pip install .\[all\] | |
| - name: Get version from package | |
| id: get_version | |
| run: | | |
| VERSION=$(python -c "import skrobot; print(skrobot.__version__)") | |
| echo "Detected version: $VERSION" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Tag and push release | |
| run: | | |
| git tag "v${{ steps.get_version.outputs.version }}" | |
| git push origin "v${{ steps.get_version.outputs.version }}" | |
| pypi: | |
| name: Release To PyPi | |
| needs: tag-release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Install publishing dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install setuptools wheel | |
| - name: Build | |
| run: | | |
| python setup.py sdist | |
| python setup.py bdist_wheel | |
| - name: Upload to PyPI | |
| uses: pypa/gh-action-pypi-publish@master | |
| with: | |
| password: ${{ secrets.PYPI_TOKEN }} |