Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pypi_publish.yml « workflows « .github - github.com/nanopb/nanopb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b2243a78bea43b08c6180f67dfed61b6a662a4bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Publish generator package to PyPI / pip

on:
  workflow_dispatch:
  workflow_call:
    secrets:
      PYPI_API_KEY:
        required: true

jobs:
  publish_pypi:
    name: Build and publish pypi package on Ubuntu 20.04
    runs-on: ubuntu-20.04

    steps:
      - name: Check out code from GitHub
        uses: actions/checkout@v2
        with:
          path: nanopb
          fetch-depth: "0"

      - name: Install dependencies
        run: |
          python3 -m pip install --user --upgrade pyinstaller poetry protobuf grpcio-tools
      
      - name: Build PyPI package
        run: |
          cd nanopb/extra/poetry
          ./poetry_build.sh

      - name: Fingerprint package
        run: |
          openssl sha256 nanopb/extra/poetry/dist/*.whl
      
      - name: Check for existence of PyPI package
        run: |
          VERSION=$(grep "^version =" nanopb/extra/poetry/build/pyproject.toml | cut -d '"' -f 2)
          if curl --head --silent --fail https://pypi.org/project/nanopb/$VERSION/; then
            echo "pypi_exists=true" >> $GITHUB_ENV
          else
            echo "pypi_exists=false" >> $GITHUB_ENV
          fi

      - name: Publish PyPI package
        if: env.pypi_exists == 'false'
        env:
          POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_KEY }}
          POETRY_HTTP_BASIC_PYPI_USERNAME: __token__
          POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_API_KEY }}
        run: |
          cd nanopb/extra/poetry/build
          poetry publish -n -v -u __token__ -p "$POETRY_PYPI_TOKEN_PYPI"

  test_pypi:
    name: Test pypi package
    runs-on: ubuntu-20.04
    needs: publish_pypi

    steps:
      - name: Check out code from GitHub
        uses: actions/checkout@v2
        with:
          path: nanopb

      - name: Wait for package to become visible
        run: |
          sleep 60

      - name: Install PyPI package
        run: |
          python3 -m pip install --user --upgrade protobuf grpcio-tools scons
          python3 -m pip install --user --upgrade --pre nanopb

      - name: Test PyPI package
        run: |
          cd nanopb/tests/alltypes/
          nanopb_generator alltypes.proto
          gcc -Wall -I ../../ -c alltypes.pb.c