-
Notifications
You must be signed in to change notification settings - Fork 3
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 #36 from UW-SASWE/publish-on-release
Create python-package-conda.yml
- Loading branch information
Showing
5 changed files
with
109 additions
and
85 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,66 @@ | ||
name: publish-to-pypi | ||
|
||
on: | ||
release: | ||
types: [ created ] | ||
|
||
jobs: | ||
build: | ||
name: Build and Publish to PyPI | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
- name: Install pypa/build | ||
run: >- | ||
python -m pip install build --user | ||
- name: Extract tag name | ||
id: tag | ||
run: | | ||
# from refs/tags/v1.2.3 get 1.2.3 | ||
VERSION=$(echo $GITHUB_REF | sed 's#.*/##') | ||
PLACEHOLDER='version = \"develop\"' | ||
VERSION_FILE1='setup.py' | ||
VERSION_FILE2='pyproject.toml' | ||
echo "VERSION=$VERSION" | ||
echo "PLACEHOLDER=$PLACEHOLDER" | ||
echo "VERSION_FILE1=$VERSION_FILE1" | ||
echo "VERSION_FILE2=$VERSION_FILE2" | ||
# ensure the placeholder is there. If grep doesn't find the placeholder | ||
# it exits with exit code 1 and github actions aborts the build. | ||
grep "$PLACEHOLDER" "$VERSION_FILE1" | ||
grep "$PLACEHOLDER" "$VERSION_FILE2" | ||
sed -i "s/$PLACEHOLDER/version = \"${VERSION}\"/g" "$VERSION_FILE1" | ||
sed -i "s/$PLACEHOLDER/version = \"${VERSION}\"/g" "$VERSION_FILE2" | ||
shell: bash | ||
- name: Build a binary wheel and a source tarball | ||
run: >- | ||
python -m build --sdist --wheel --outdir dist/ . | ||
- name: Upload artifact to GA | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist/ | ||
retention-days: 5 | ||
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` | ||
|
||
publish: | ||
name: Publish distribution to PyPI | ||
needs: [build] | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags') | ||
steps: | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist | ||
- name: Upload to artifact PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_TOKEN }} | ||
skip_existing: true |
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
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
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