|
| 1 | +name: Toolkit Library Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'toolkit/**/*' |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + comment-id: |
| 12 | + description: 'The comment-id of the slash command' |
| 13 | + required: true |
| 14 | + event-number: |
| 15 | + description: 'The event-id of the slash command' |
| 16 | + required: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + publish-library: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + with: |
| 24 | + persist-credentials: false |
| 25 | + ref: ${{ github.ref }} |
| 26 | + - name: Install poetry |
| 27 | + run: pip install poetry |
| 28 | + - name: Set up Python |
| 29 | + uses: actions/setup-python@v2 |
| 30 | + with: |
| 31 | + python-version: 3.9.5 |
| 32 | + - name: Metadata |
| 33 | + id: metadata |
| 34 | + run: echo "::set-output name=commit::$(git rev-parse HEAD)" |
| 35 | + - name: Find Release Comment |
| 36 | + uses: peter-evans/find-comment@v1 |
| 37 | + id: find_comment |
| 38 | + if: ${{ github.ref != 'refs/heads/main' }} |
| 39 | + with: |
| 40 | + token: ${{ secrets.BOT_TOKEN }} |
| 41 | + issue-number: ${{ github.event.inputs.event-number }} |
| 42 | + comment-author: pythonitaliabot |
| 43 | + body-includes: "Pre-release" |
| 44 | + - name: Create or update comment |
| 45 | + id: initial-comment |
| 46 | + uses: peter-evans/create-or-update-comment@v1 |
| 47 | + if: ${{ github.ref != 'refs/heads/main' }} |
| 48 | + with: |
| 49 | + token: ${{ secrets.BOT_TOKEN }} |
| 50 | + comment-id: ${{ steps.find_comment.outputs.comment-id }} |
| 51 | + issue-number: ${{ github.event.inputs.event-number }} |
| 52 | + body: | |
| 53 | + # Pre-release |
| 54 | + :wave: |
| 55 | +
|
| 56 | + Releasing commit [${{ steps.metadata.outputs.commit }}] to PyPi as pre-release! :package: |
| 57 | + edit-mode: replace |
| 58 | + - name: Update version |
| 59 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 60 | + run: poetry version patch |
| 61 | + - name: Update to pre-release version |
| 62 | + if: ${{ github.ref != 'refs/heads/main' }} |
| 63 | + run: | |
| 64 | + poetry version patch |
| 65 | + poetry version $(poetry version -s)-dev.$(date '+%s') |
| 66 | + - name: Build & Publish |
| 67 | + id: release |
| 68 | + env: |
| 69 | + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} |
| 70 | + run: | |
| 71 | + poetry publish --username __token__ --build |
| 72 | + echo "::set-output name=version::$(poetry version -s)" |
| 73 | + - name: Commit version |
| 74 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 75 | + env: |
| 76 | + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} |
| 77 | + run: | |
| 78 | + git remote set-url origin https://${{ secrets.BOT_TOKEN }}@github.com/${{ github.repository }} |
| 79 | +
|
| 80 | + git config user.name "Python Italia [bot]" |
| 81 | + git config user.email "noreply@python.it" |
| 82 | +
|
| 83 | + git add pyproject.toml |
| 84 | + git commit -m "🔨 Publish Toolkit v$(poetry version -s) [skip ci]" |
| 85 | + git push |
| 86 | + - name: Create or update comment |
| 87 | + uses: peter-evans/create-or-update-comment@v1 |
| 88 | + if: ${{ github.ref != 'refs/heads/main' }} |
| 89 | + with: |
| 90 | + token: ${{ secrets.BOT_TOKEN }} |
| 91 | + comment-id: ${{ steps.initial-comment.outputs.comment-id }} |
| 92 | + issue-number: ${{ github.event.inputs.event-number }} |
| 93 | + body: | |
| 94 | + # Pre-release |
| 95 | + :wave: |
| 96 | +
|
| 97 | + Pre-release **${{ steps.release.outputs.version }}** [${{ steps.metadata.outputs.commit }}] has been released on PyPi! :rocket: |
| 98 | + You can try it by doing: |
| 99 | +
|
| 100 | + ```shell |
| 101 | + poetry add pythonit-toolkit==${{ steps.release.outputs.version }} |
| 102 | + ``` |
| 103 | + edit-mode: replace |
0 commit comments