|
1 | | -# This workflow will upload a Python Package using Twine when a Lemur release is created via github |
2 | | -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries |
| 1 | +# This workflow will upload a Python Package to PyPI when a Lemur release is created via github |
| 2 | +# For more information see: https://github.com/marketplace/actions/pypi-publish |
3 | 3 |
|
4 | 4 | name: Publish Lemur's latest package to PyPI |
5 | 5 |
|
|
8 | 8 | types: [created] |
9 | 9 |
|
10 | 10 | jobs: |
11 | | - deploy: |
12 | | - |
| 11 | + build: |
| 12 | + name: Build distribution |
13 | 13 | runs-on: ubuntu-latest |
14 | | - |
15 | 14 | steps: |
16 | | - - uses: actions/checkout@v4 |
17 | | - - name: Set up Python |
18 | | - uses: actions/setup-python@v5 |
19 | | - with: |
20 | | - python-version: '3.x' |
21 | | - - name: Autobump version |
22 | | - run: | |
23 | | - # from refs/tags/v0.8.1 get 0.8.1 |
24 | | - VERSION=$(echo $GITHUB_REF | sed 's#.*/v##') |
25 | | - PLACEHOLDER='^__version__ =.*' |
26 | | - VERSION_FILE='lemur/__about__.py' |
27 | | - # in case placeholder is missing, exists with code 1 and github actions aborts the build |
28 | | - grep "$PLACEHOLDER" "$VERSION_FILE" |
29 | | - sed -i "s/$PLACEHOLDER/__version__ = \"${VERSION}\"/g" "$VERSION_FILE" |
30 | | - shell: bash |
31 | | - - name: Install dependencies |
32 | | - run: | |
33 | | - python -m pip install --upgrade pip |
34 | | - pip install setuptools wheel twine |
35 | | - - name: Build and publish |
36 | | - env: |
37 | | - TWINE_USERNAME: ${{ secrets.LEMUR_PYPI_API_USERNAME }} |
38 | | - TWINE_PASSWORD: ${{ secrets.LEMUR_PYPI_API_TOKEN }} |
39 | | - run: | |
40 | | - python setup.py sdist bdist_wheel |
41 | | - twine upload dist/* |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + - name: Set up Python |
| 17 | + uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version: '3.x' |
| 20 | + - name: Autobump version |
| 21 | + run: | |
| 22 | + # from refs/tags/v0.8.1 get 0.8.1 |
| 23 | + VERSION=$(echo $GITHUB_REF | sed 's#.*/v##') |
| 24 | + PLACEHOLDER='^__version__ =.*' |
| 25 | + VERSION_FILE='lemur/__about__.py' |
| 26 | + # in case placeholder is missing, exists with code 1 and github actions aborts the build |
| 27 | + grep "$PLACEHOLDER" "$VERSION_FILE" |
| 28 | + sed -i "s/$PLACEHOLDER/__version__ = \"${VERSION}\"/g" "$VERSION_FILE" |
| 29 | + shell: bash |
| 30 | + - name: Install dependencies |
| 31 | + run: | |
| 32 | + python -m pip install --upgrade pip |
| 33 | + pip install setuptools wheel |
| 34 | + - name: Build package |
| 35 | + run: | |
| 36 | + python setup.py sdist bdist_wheel |
| 37 | + - name: Store the distribution packages |
| 38 | + uses: actions/upload-artifact@v3 |
| 39 | + with: |
| 40 | + name: python-package-distributions |
| 41 | + path: dist/ |
| 42 | + pypi-publish: |
| 43 | + name: upload release to PyPI |
| 44 | + runs-on: ubuntu-latest |
| 45 | + environment: |
| 46 | + name: release |
| 47 | + url: https://pypi.org/p/lemur |
| 48 | + permissions: |
| 49 | + # https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-pypi |
| 50 | + id-token: write |
| 51 | + steps: |
| 52 | + - name: Download all the dists |
| 53 | + uses: actions/download-artifact@v3 |
| 54 | + with: |
| 55 | + name: python-package-distributions |
| 56 | + path: dist/ |
| 57 | + - name: Publish package distributions to PyPI |
| 58 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments