Skip to content

Commit

Permalink
Merge pull request #36 from UW-SASWE/publish-on-release
Browse files Browse the repository at this point in the history
Create python-package-conda.yml
  • Loading branch information
SanchitMinocha authored May 10, 2023
2 parents 0e47728 + 7b82216 commit 5bbcefc
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 85 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/python-package-pypi.yaml
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
68 changes: 39 additions & 29 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
name: Python package
name: build-and-test

on: [push]
on: [push, pull_request]

jobs:
build:
name: Build package
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: 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`

test:
name: Test package
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -21,36 +46,21 @@ jobs:
python-version: ${{ matrix.python-version }}
environment-file: test_env.yml
activate-environment: rat_test_env
# - name: Test conda
# shell: bash -l {0}
# run: |
# which conda
# conda info
# conda env list
# conda env export --from-history
# - name: Build and install RAT
# shell: bash -l {0}
# run: |
# conda build .
# conda install -c file://${CONDA_PREFIX}/conda-bld/ rat
# - name: Test RAT
# shell: bash -l {0}
# run: |
# mkdir ~/rat_test
# rat init -d ~/rat_test
# rat test -d ~/rat_test
- name: Install RAT (develop mode)
- name: Test conda
shell: bash -l {0}
run: |
which conda
conda info
conda env list
conda env export --from-history
- name: Build and install RAT
shell: bash -l {0}
run: |
mamba env update --file environment.yml
conda develop src/
conda build conda
conda install -c file://${CONDA_PREFIX}/conda-bld/ rat
- name: Test RAT
shell: bash -l {0}
run: |
mkdir ~/rat_test
which conda
which python
conda list
mamba install ruamel.yaml --force-reinstall
python src/rat/cli/rat_cli.py init -d ~/rat_test -s ${{ secrets.SECRETS }}
python src/rat/cli/rat_cli.py test -d ~/rat_test -s ${{ secrets.SECRETS }}
rat init -d ~/rat_test
rat test -d ~/rat_test
51 changes: 0 additions & 51 deletions meta.yaml

This file was deleted.

5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "rat"
version = "3.0.0.alpha.2"
version = "develop"
authors = [
{ name="Pritam Das", email="pdas47@uw.edu" },
{ name="Sanchit Minocha", email="msanchit@uw.edu" },
Expand All @@ -15,8 +15,7 @@ readme = "README.md"
license = {file = "LICENSE"}
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License"
]

[project.urls]
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name = "rat",
version = "3.0.0.alpha.2",
version = "develop",
license = "GPL-3.0",
package_dir = {"": "src"}
)
)

0 comments on commit 5bbcefc

Please sign in to comment.