Merge pull request #27 from sandialabs/dependabot/github_actions/code… #18
Workflow file for this run
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
name: package | |
on: | |
push: | |
tags: | |
- '*' | |
jobs: | |
get-version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- id: version | |
run: | | |
export VERSION=$(grep __version__ statmechcrack/__init__.py | cut -f2 -d '"') | |
echo "::set-output name=VERSION::${VERSION}" | |
outputs: | |
VERSION: ${{ steps.version.outputs.VERSION }} | |
pypi: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install --upgrade setuptools | |
pip install wheel twine | |
- name: Make tarball | |
run: python setup.py sdist | |
- name: Make wheel | |
run: python setup.py bdist_wheel | |
- name: Upload to PyPI.org | |
run: twine upload -u __token__ -p ${{ secrets.PYPI_TOKEN }} dist/* | |
- name: Give upload time before downloading | |
run: sleep 500s | |
test-pypi: | |
needs: [get-version, pypi] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install and test the package | |
run: | | |
python -m pip install --upgrade pip | |
pip install statmechcrack==${{ needs.get-version.outputs.VERSION }} | |
python -m statmechcrack.tests | |
anaconda: | |
needs: [get-version, pypi] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare conda | |
run: | | |
rm -rf statmechcrack | |
conda update conda | |
conda install anaconda-client conda-build | |
- name: Create conda recipe from PyPI | |
run: conda skeleton pypi --noarch-python --version ${{ needs.get-version.outputs.VERSION }} statmechcrack | |
- name: Edit meta.yml | |
run: | | |
sed -i 's@dev_url:@& \"https://github.com/sandialabs/'statmechcrack'\"@' statmechcrack/meta.yaml | |
sed -i 's@doc_url:@& \"https://'statmechcrack'.readthedocs.io\"@' statmechcrack/meta.yaml | |
cp LICENSE statmechcrack/LICENSE | |
sed -i 's@license_file:@& LICENSE@' statmechcrack/meta.yaml | |
sed -i '/license_file/a \ \ license_url:' statmechcrack/meta.yaml | |
sed -i 's@license_url:@& \"https://github.com/sandialabs/'statmechcrack'/blob/main/LICENSE\"@' statmechcrack/meta.yaml | |
sed -i 's@your-github-id-here@mrbuche@' statmechcrack/meta.yaml | |
sed -i "s@license: BSD@license: BSD-3-Clause@" statmechcrack/meta.yaml | |
sudo apt install -y pandoc | |
pandoc -s -o README.md README.rst | |
sed -e 's/title: //g' -i README.md | |
sed -i 's/^/ /' README.md | |
sed -i '/summary/a \ \ description: |' statmechcrack/meta.yaml | |
sed -i '/doc_url/e cat README.md' statmechcrack/meta.yaml | |
cat statmechcrack/meta.yaml | |
- name: Build conda packages | |
run: conda build --python 3.9 statmechcrack | |
- name: Upload to Anaconda.org | |
run: | | |
PATH="/usr/share/miniconda/bin/:$PATH" | |
export ANACONDA_API_TOKEN=${{ secrets.ANACONDA_TOKEN }} | |
anaconda upload --user mrbuche --force /usr/share/miniconda/conda-bld/noarch/statmechcrack*.tar.bz2 | |
- name: Give upload time before downloading | |
run: sleep 500s | |
test-anaconda: | |
needs: [get-version, anaconda] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install the package | |
run: conda install --channel mrbuche statmechcrack==${{ needs.get-version.outputs.VERSION }} | |
- name: Test the package | |
run: | | |
conda init | |
conda list | |
PATH="/usr/share/miniconda/bin/:$PATH" | |
python -c 'import statmechcrack' | |
python -m statmechcrack.tests |