forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: automate publishing to pypi (#58)
* feat: automate publishing to pypi * feat: ensure version is in package and changelog * feat: sync up master after release Signed-off-by: heitorlessa <lessa@amazon.co.uk> * chore: document release process in action Signed-off-by: heitorlessa <lessa@amazon.co.uk> * improv: use exact match for release tag version Signed-off-by: heitorlessa <lessa@amazon.co.uk> * fix: PYPI_USERNAME typo Signed-off-by: heitorlessa <lessa@amazon.co.uk>
- Loading branch information
1 parent
b010833
commit b40c9bd
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Publish to PyPi | ||
|
||
# RELEASE PROCESS | ||
# | ||
# === Manual activities === | ||
# | ||
# 1. Document human readable changes in CHANGELOG | ||
# 2. Bump package version using poetry version <major|minor|patch|specific version> | ||
# 3. Create a PR to develop branch, and merge if all tests pass | ||
# 4. Edit the current draft release notes | ||
# 5. If not already set, use `v<new version>` as a tag, and select develop as target branch | ||
# | ||
# === Automated activities === | ||
# | ||
# 1. Extract release notes tag that was published | ||
# 2. Ensure release notes tag match what's in CHANGELOG and pyproject | ||
# 3. Run tests, linting, security and complexity base line | ||
# 4. Publish package to PyPi test repository | ||
# 5. Publish package to PyPi prod repository | ||
# 6. Push latest release source code to master using release title as the commit message | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
upload: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: "3.8" | ||
- name: Set release notes tag | ||
run: | | ||
export RELEASE_TAG_VERSION=${{ github.event.release.tag_name }} | ||
echo ::set-env name=RELEASE_TAG_VERSION::${RELEASE_TAG_VERSION:1} | ||
- name: Ensure new version is also set in pyproject and CHANGELOG | ||
run: | | ||
grep --regexp "\[${RELEASE_TAG_VERSION}\]" CHANGELOG.md | ||
grep --regexp "version \= \"${RELEASE_TAG_VERSION}\"" pyproject.toml | ||
- name: Install dependencies | ||
run: make dev | ||
- name: Run all tests, linting and baselines | ||
run: make pr | ||
- name: Build python package and wheel | ||
run: poetry build | ||
- name: Upload to PyPi test | ||
run: make release-test | ||
env: | ||
PYPI_USERNAME: __token__ | ||
PYPI_TOKEN: ${{ secrets.PYPI_TEST_TOKEN }} | ||
- name: Upload to PyPi prod | ||
run: make release-prod | ||
env: | ||
PYPI_USERNAME: __token__ | ||
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | ||
|
||
sync_master: | ||
needs: upload | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Sync master from detached head | ||
# If version matches CHANGELOG and pyproject.toml | ||
# If it passes all checks, successfully releases to test and prod | ||
# Then sync up master with latest source code release | ||
# where commit message will be Release notes title | ||
run: git push origin HEAD:refs/heads/master --force |