|
| 1 | +name: Publish to PyPi |
| 2 | + |
| 3 | +# RELEASE PROCESS |
| 4 | +# |
| 5 | +# === Manual activities === |
| 6 | +# |
| 7 | +# 1. Document human readable changes in CHANGELOG |
| 8 | +# 2. Bump package version using poetry version <major|minor|patch|specific version> |
| 9 | +# 3. Create a PR to develop branch, and merge if all tests pass |
| 10 | +# 4. Edit the current draft release notes |
| 11 | +# 5. If not already set, use `v<new version>` as a tag, and select develop as target branch |
| 12 | +# |
| 13 | +# === Automated activities === |
| 14 | +# |
| 15 | +# 1. Extract release notes tag that was published |
| 16 | +# 2. Ensure release notes tag match what's in CHANGELOG and pyproject |
| 17 | +# 3. Run tests, linting, security and complexity base line |
| 18 | +# 4. Publish package to PyPi test repository |
| 19 | +# 5. Publish package to PyPi prod repository |
| 20 | +# 6. Push latest release source code to master using release title as the commit message |
| 21 | + |
| 22 | +on: |
| 23 | + release: |
| 24 | + types: [published] |
| 25 | + |
| 26 | +jobs: |
| 27 | + upload: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v2 |
| 31 | + - name: Set up Python |
| 32 | + uses: actions/setup-python@v1 |
| 33 | + with: |
| 34 | + python-version: "3.8" |
| 35 | + - name: Set release notes tag |
| 36 | + run: | |
| 37 | + export RELEASE_TAG_VERSION=${{ github.event.release.tag_name }} |
| 38 | + echo ::set-env name=RELEASE_TAG_VERSION::${RELEASE_TAG_VERSION:1} |
| 39 | + - name: Ensure new version is also set in pyproject and CHANGELOG |
| 40 | + run: | |
| 41 | + grep --regexp "\[${RELEASE_TAG_VERSION}\]" CHANGELOG.md |
| 42 | + grep --regexp "version \= \"${RELEASE_TAG_VERSION}\"" pyproject.toml |
| 43 | + - name: Install dependencies |
| 44 | + run: make dev |
| 45 | + - name: Run all tests, linting and baselines |
| 46 | + run: make pr |
| 47 | + - name: Build python package and wheel |
| 48 | + run: poetry build |
| 49 | + - name: Upload to PyPi test |
| 50 | + run: make release-test |
| 51 | + env: |
| 52 | + PYPI_USERNAME: __token__ |
| 53 | + PYPI_TOKEN: ${{ secrets.PYPI_TEST_TOKEN }} |
| 54 | + - name: Upload to PyPi prod |
| 55 | + run: make release-prod |
| 56 | + env: |
| 57 | + PYPI_USERNAME: __token__ |
| 58 | + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} |
| 59 | + |
| 60 | + sync_master: |
| 61 | + needs: upload |
| 62 | + runs-on: ubuntu-latest |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v2 |
| 65 | + - name: Sync master from detached head |
| 66 | + # If version matches CHANGELOG and pyproject.toml |
| 67 | + # If it passes all checks, successfully releases to test and prod |
| 68 | + # Then sync up master with latest source code release |
| 69 | + # where commit message will be Release notes title |
| 70 | + run: git push origin HEAD:refs/heads/master --force |
0 commit comments