|
| 1 | +name: release |
| 2 | + |
| 3 | +# Release Python client library on successful completion of the `test` workflow |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_run: |
| 7 | + workflows: |
| 8 | + - test |
| 9 | + branches: [ main ] |
| 10 | + types: |
| 11 | + - completed |
| 12 | + |
| 13 | +jobs: |
| 14 | + |
| 15 | + tag-release: |
| 16 | + name: tag-release - Python 3.9 (ubuntu-latest) |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + upload_url: ${{ steps.create-release.outputs.upload_url }} |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + with: |
| 24 | + fetch-depth: 2 |
| 25 | + |
| 26 | + # Python setup |
| 27 | + - name: Set up Python environment |
| 28 | + uses: actions/setup-python@v2 |
| 29 | + with: |
| 30 | + python-version: "3.9" |
| 31 | + |
| 32 | + # Install dependencies |
| 33 | + - name: Install dependencies |
| 34 | + run: | |
| 35 | + python -m pip install --upgrade pip setuptools wheel |
| 36 | + pip install -r requirements.txt |
| 37 | + pip install -r requirements_dev.txt |
| 38 | +
|
| 39 | + # Tag the commit with the library version |
| 40 | + - name: Create git tag |
| 41 | + uses: salsify/action-detect-and-tag-new-version@v2 |
| 42 | + with: |
| 43 | + version-command: cat VERSION |
| 44 | + |
| 45 | + # Set release output variables |
| 46 | + - name: Set output |
| 47 | + id: vars |
| 48 | + run: | |
| 49 | + echo "::set-output name=tag_name::v$(cat VERSION)" |
| 50 | + echo "::set-output name=release_name::$(cat VERSION)" |
| 51 | +
|
| 52 | + # Create GitHub release |
| 53 | + - name: Create release |
| 54 | + id: create-release |
| 55 | + uses: actions/create-release@v1 |
| 56 | + env: |
| 57 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + TAG_NAME: ${{ steps.vars.outputs.tag_name }} |
| 59 | + RELEASE_NAME: ${{ steps.vars.outputs.release_name }} |
| 60 | + with: |
| 61 | + tag_name: ${{ env.TAG_NAME }} |
| 62 | + release_name: ${{ env.RELEASE_NAME }} |
| 63 | + draft: false |
| 64 | + prerelease: false |
| 65 | + |
| 66 | + publish: |
| 67 | + needs: [ tag-release ] |
| 68 | + name: publish-sdist - Python 3.9 (ubuntu-latest) |
| 69 | + runs-on: ubuntu-latest |
| 70 | + |
| 71 | + steps: |
| 72 | + - uses: actions/checkout@v2 |
| 73 | + |
| 74 | + # Python setup |
| 75 | + - name: Set up Python environment |
| 76 | + uses: actions/setup-python@v2 |
| 77 | + with: |
| 78 | + python-version: "3.9" |
| 79 | + |
| 80 | + # Install release dependencies |
| 81 | + - name: Install release dependencies |
| 82 | + run: python -m pip install --upgrade pip setuptools wheel twine |
| 83 | + |
| 84 | + # Set release output variables |
| 85 | + - name: Set output |
| 86 | + id: vars |
| 87 | + run: | |
| 88 | + echo "::set-output name=asset_path::$(find ./dist -mindepth 1 -print -quit)" |
| 89 | + cd dist |
| 90 | + echo "::set-output name=asset_name::$(printf '%s\0' * | awk 'BEGIN{RS="\0"} {print; exit}')" |
| 91 | +
|
| 92 | + # Create distributions |
| 93 | + - name: Package for release |
| 94 | + run: python setup.py sdist bdist_wheel |
| 95 | + |
| 96 | + # Upload release asset |
| 97 | + - name: Upload release asset |
| 98 | + id: upload-release-asset |
| 99 | + uses: actions/upload-release-asset@v1 |
| 100 | + env: |
| 101 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 102 | + ASSET_PATH: ${{ steps.vars.outputs.asset_path }} |
| 103 | + ASSET_NAME: ${{ steps.vars.outputs.asset_name }} |
| 104 | + with: |
| 105 | + upload_url: ${{ needs.tag-release.outputs.upload_url }} |
| 106 | + asset_path: ${{ env.ASSET_PATH }} |
| 107 | + asset_name: ${{ env.ASSET_NAME }} |
| 108 | + asset_content_type: application/zip |
| 109 | + |
| 110 | + # Publish to PyPI |
| 111 | + - name: Publish to PyPI |
| 112 | + run: python twine upload -r databento -u ${{ secrets.PYPI_USERNAME }} - p ${{ secrets.PYPI_TOKEN }} |
0 commit comments