-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from mbeacom/enable-auto-release
Enable automatic release to PyPi on tag
- Loading branch information
Showing
1 changed file
with
77 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,77 @@ | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
name: Create & Publish Package | ||
|
||
jobs: | ||
publish: | ||
name: Create & Publish Package | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- name: Checkout Source | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.7' | ||
|
||
- name: Cache Poetry | ||
id: cache-poetry | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.poetry | ||
key: poetry | ||
|
||
- name: Install Poetry | ||
if: steps.cache-poetry.outputs.cache-hit != 'true' | ||
run: | | ||
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -O | ||
python install-poetry.py --preview | ||
- name: Add Poetry to $PATH | ||
run: echo "$HOME/.poetry/bin" >> $GITHUB_PATH | ||
|
||
- name: Add versioning plugin | ||
run: poetry plugin add poetry-version-plugin | ||
|
||
- name: Poetry Version | ||
run: poetry --version | ||
|
||
- name: Add version to environment vars | ||
run: echo "MODULE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
- name: Check if source version is up-to-date | ||
run: | | ||
TAG=$(git describe HEAD --tags --abbrev=0) | ||
echo Current Tag: $TAG -- Current Module Version: $MODULE_VERSION | ||
if [[ "$TAG" != "$MODULE_VERSION" ]]; then exit 1; fi | ||
- name: Check pyproject.toml validity | ||
run: poetry check --no-interaction | ||
|
||
- name: Cache Dependencies | ||
id: cache-deps | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{github.workspace}}/.venv | ||
key: poetry-${{ hashFiles('**/poetry.lock') }} | ||
restore-keys: poetry- | ||
|
||
- name: Install deps | ||
if: steps.cache-deps.cache-hit != 'true' | ||
run: | | ||
poetry config virtualenvs.in-project true | ||
poetry install --no-interaction | ||
- name: Build Package | ||
run: poetry build | ||
|
||
- name: Publish to PyPi | ||
run: poetry publish -u __token__ -p $PYPI_TOKEN | ||
env: | ||
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} |