-
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.
- Loading branch information
Showing
1 changed file
with
107 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,107 @@ | ||
# Builds and publishes to testpypi on every push to main | ||
# On release, publishes to pypi | ||
name: publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
release: | ||
types: [published] | ||
|
||
env: | ||
PYTHON_VERSION: 3.8 | ||
DUNAMAI_VERSION: 1.8.0 | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
cache: "poetry" | ||
|
||
- name: Set version with dunamai | ||
uses: mtkennerly/dunamai-action@v1 | ||
with: | ||
env-var: LIB_VERSION | ||
command: dunamai from git | ||
args: --no-metadata --style semver | ||
|
||
- run: echo $LIB_VERSION | ||
- run: poetry version $LIB_VERSION | ||
|
||
- name: poetry build | ||
run: poetry build | ||
|
||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: poetry_build | ||
path: dist/ | ||
|
||
publish_test_pypi: | ||
if: github.repository_owner == 'ryankanno' | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
cache: "poetry" | ||
|
||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: poetry_build | ||
path: dist/ | ||
|
||
- name: Install Poetry | ||
run: python -m pip install poetry | ||
|
||
- name: poetry configure TestPyPI Repo | ||
run: poetry config repositories.test-pypi https://test.pypi.org/legacy/ | ||
|
||
- name: poetry configure TestPyPI Token | ||
run: poetry config pypi-token.test-pypi ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
|
||
- name: poetry publish TestPyPi | ||
run: poetry publish -r test-pypi | ||
|
||
publish_pypi: | ||
if: github.repository_owner == 'ryankanno' && github.event_name == 'release' && github.event.action == 'published' | ||
runs-on: ubuntu-latest | ||
needs: publish_test_pypi | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
cache: "poetry" | ||
|
||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: poetry_build | ||
path: dist/ | ||
|
||
- name: Install Poetry | ||
run: python -m pip install poetry | ||
|
||
- name: poetry configure PyPI Token | ||
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} | ||
|
||
- name: poetry publish PyPi | ||
run: poetry publish |