|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - master |
| 8 | + |
| 9 | +jobs: |
| 10 | + release: |
| 11 | + name: Release |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Check out the repository |
| 15 | + uses: actions/checkout@v3 |
| 16 | + with: |
| 17 | + fetch-depth: 2 |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v4 |
| 21 | + with: |
| 22 | + python-version: "3.10" |
| 23 | + |
| 24 | + - name: Upgrade pip |
| 25 | + run: | |
| 26 | + pip install --constraint=.github/workflows/constraints.txt pip |
| 27 | + pip --version |
| 28 | +
|
| 29 | + - name: Install Poetry |
| 30 | + run: | |
| 31 | + pip install --constraint=.github/workflows/constraints.txt poetry |
| 32 | + poetry --version |
| 33 | +
|
| 34 | + - name: Check if there is a parent commit |
| 35 | + id: check-parent-commit |
| 36 | + run: | |
| 37 | + echo "::set-output name=sha::$(git rev-parse --verify --quiet HEAD^)" |
| 38 | +
|
| 39 | + - name: Detect and tag new version |
| 40 | + id: check-version |
| 41 | + if: steps.check-parent-commit.outputs.sha |
| 42 | + uses: salsify/action-detect-and-tag-new-version@v2.0.1 |
| 43 | + with: |
| 44 | + version-command: | |
| 45 | + bash -o pipefail -c "poetry version | awk '{ print \$2 }'" |
| 46 | +
|
| 47 | + - name: Bump version for developmental release |
| 48 | + if: "! steps.check-version.outputs.tag" |
| 49 | + run: | |
| 50 | + poetry version patch && |
| 51 | + version=$(poetry version | awk '{ print $2 }') && |
| 52 | + poetry version $version.dev.$(date +%s) |
| 53 | +
|
| 54 | + - name: Build package |
| 55 | + run: | |
| 56 | + poetry build --ansi |
| 57 | +
|
| 58 | + # - name: Publish package on PyPI |
| 59 | + # if: steps.check-version.outputs.tag |
| 60 | + # uses: pypa/gh-action-pypi-publish@v1.5.0 |
| 61 | + # with: |
| 62 | + # user: __token__ |
| 63 | + # password: ${{ secrets.PYPI_TOKEN }} |
| 64 | + # |
| 65 | + # - name: Publish package on TestPyPI |
| 66 | + # if: "! steps.check-version.outputs.tag" |
| 67 | + # uses: pypa/gh-action-pypi-publish@v1.5.0 |
| 68 | + # with: |
| 69 | + # user: __token__ |
| 70 | + # password: ${{ secrets.TEST_PYPI_TOKEN }} |
| 71 | + # repository_url: https://test.pypi.org/legacy/ |
| 72 | + |
| 73 | + - name: Publish the release notes |
| 74 | + uses: release-drafter/release-drafter@v5.20.0 |
| 75 | + with: |
| 76 | + publish: ${{ steps.check-version.outputs.tag != '' }} |
| 77 | + tag: ${{ steps.check-version.outputs.tag }} |
| 78 | + env: |
| 79 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments