diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 00000000..1da20886 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,19 @@ +on: + release: + types: + - published + +jobs: + publish: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Poetry Setup + uses: abatilo/actions-poetry@v2.1.2 + - name: Publish to PyPI + env: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: | + poetry config pypi-token.pypi $PYPI_TOKEN + poetry publish --build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 105cd240..7ef85d06 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,11 +6,27 @@ on: - "v*" jobs: + pypi: + name: Publish to PyPI + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Poetry Setup + uses: abatilo/actions-poetry@v2.1.2 + - name: Publish to PyPI + env: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: | + poetry publish --build -n --username __token__ --password "$PYPI_TOKEN" + release: + name: GitHub Release runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v3 - name: Build tools run: | @@ -21,6 +37,31 @@ jobs: run: | sudo apt-get install -y python3 python3-pip python-is-python3 + - name: Poetry Setup + uses: abatilo/actions-poetry@v2.1.2 + + # Poetry cache with default ~.cache/pypoetry directory. + # Update it when `poetry.lock` file changed. + - name: Cache Poetry + id: cache-poetry + uses: actions/cache@v2.1.5 + with: + path: ~/.cache/pypoetry + key: ubuntu-20.04-poetry-${{ hashFiles('**/poetry.lock') }} + + #---------------------------------------------- + # install dependencies if cache does not exist + #---------------------------------------------- + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + + #---------------------------------------------- + # install your root project, if required + #---------------------------------------------- + - name: Install library + run: poetry install --no-interaction + - name: Set up Go uses: actions/setup-go@v2 with: @@ -47,50 +88,12 @@ jobs: ./TDengine/build/build/bin/taosadapter & ./TDengine/build/build/bin/taosd -c /tmp/taos/ & - - name: Cache Poetry - id: cache-poetry - uses: actions/cache@v2.1.5 - with: - path: ~/.poetry - key: ubuntu-20.04-poetry - #---------------------------------------------- - # ----- install & configure poetry ----- - #---------------------------------------------- - - name: Install Poetry - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - installer-parallel: true - - #---------------------------------------------- - # load cached venv if cache exists - #---------------------------------------------- - - name: Load cached venv - id: cached-poetry-dependencies - uses: actions/cache@v2 - with: - path: .venv - key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} - #---------------------------------------------- - # install dependencies if cache does not exist - #---------------------------------------------- - - name: Install dependencies - if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - run: poetry install --no-interaction --no-root - #---------------------------------------------- - # install your root project, if required - #---------------------------------------------- - - name: Install library - run: poetry install --no-interaction - #---------------------------------------------- # run test suite #---------------------------------------------- - name: Test run: | export LD_LIBRARY_PATH=$PWD/TDengine/build/build/lib - source $VENV poetry run pip install psutil pandas poetry run pytest tests - name: Build Artifacts @@ -108,10 +111,3 @@ jobs: body_path: ${{ github.workflow }}-CHANGELOG.txt files: | dist/* - - - name: Publish to PyPI - env: - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} - run: | - poetry config pypi-token.pypi $PYPI_TOKEN - poetry publish --build -n