|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*.*.*' |
| 7 | + - '*.*.*-*' |
| 8 | + |
| 9 | +jobs: |
| 10 | + |
| 11 | + build: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Build package using Poetry and store result |
| 15 | + uses: chaoss/grimoirelab-github-actions/build@main |
| 16 | + with: |
| 17 | + artifact-name: sh-eclipse-foundation-dist |
| 18 | + artifact-path: dist |
| 19 | + |
| 20 | + tests: |
| 21 | + needs: [build] |
| 22 | + runs-on: ubuntu-latest |
| 23 | + services: |
| 24 | + mysql: |
| 25 | + image: mariadb:10.5 |
| 26 | + env: |
| 27 | + MYSQL_ROOT_PASSWORD: root |
| 28 | + ports: |
| 29 | + - 3306:3306 |
| 30 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 31 | + |
| 32 | + name: Python ${{ matrix.python-version }} for ES ${{ matrix.elasticsearch-version }} |
| 33 | + strategy: |
| 34 | + matrix: |
| 35 | + python-version: ['3.9', '3.10', '3.11', '3.12'] |
| 36 | + |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 39 | + |
| 40 | + - name: Download distribution artifact |
| 41 | + uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 |
| 42 | + with: |
| 43 | + name: sh-eclipse-foundation-dist |
| 44 | + path: dist |
| 45 | + |
| 46 | + - name: Set up Python ${{ matrix.python-version }} |
| 47 | + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 |
| 48 | + with: |
| 49 | + python-version: ${{ matrix.python-version }} |
| 50 | + |
| 51 | + - name: Install dev dependencies |
| 52 | + run: | |
| 53 | + curl -sSL https://install.python-poetry.org | python3 - |
| 54 | + echo "PATH=$HOME/.poetry/bin:$PATH" >> $GITHUB_ENV |
| 55 | + poetry install --only dev |
| 56 | +
|
| 57 | + - name: Set MySQL mode |
| 58 | + env: |
| 59 | + DB_HOST: 127.0.0.1 |
| 60 | + DB_PORT: ${{ job.services.mysql.ports[3306] }} |
| 61 | + run: | |
| 62 | + mysql --host $DB_HOST --port $DB_PORT -uroot -proot -e "SET GLOBAL sql_mode = 'NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'"; |
| 63 | +
|
| 64 | + - name: Test package |
| 65 | + run: | |
| 66 | + PACKAGE=`(cd dist && ls *whl)` && echo $PACKAGE |
| 67 | + poetry run pip install --pre ./dist/$PACKAGE |
| 68 | + poetry run python manage.py test --settings=config.settings.testing |
| 69 | +
|
| 70 | + release: |
| 71 | + needs: [tests] |
| 72 | + runs-on: ubuntu-latest |
| 73 | + permissions: |
| 74 | + contents: write |
| 75 | + steps: |
| 76 | + - name: Create a new release on the repository |
| 77 | + uses: chaoss/grimoirelab-github-actions/release@main |
| 78 | + with: |
| 79 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + |
| 81 | + publish: |
| 82 | + needs: [tests] |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + - name: Publish the package on PyPI |
| 86 | + uses: chaoss/grimoirelab-github-actions/publish@main |
| 87 | + with: |
| 88 | + artifact-name: sh-eclipse-foundation-dist |
| 89 | + artifact-path: dist |
| 90 | + pypi-api-token: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments