Skip to content

Commit

Permalink
Add pypi jobs to release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosgjs committed Apr 10, 2023
1 parent ba9137c commit 48a2e39
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 5 deletions.
94 changes: 92 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,106 @@
name: Release

on:
release:
types: [published]
workflow_run:
workflows: [pypi]
types:
- completed
push: { branches: [carlosg/pypi] }
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-artifact:
name: Build noisepy-seis package
runs-on: ubuntu-20.04
if: github.repository == 'mdenolle/NoisePy'
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python
uses: actions/[email protected]
with:
python-version: 3.9

- name: Install dependencies
run: python -m pip install build

- name: Build source and wheel distributions
run: |
python -m build
echo ""
echo "Generated files:"
ls -lh dist/
- uses: actions/upload-artifact@v3
with:
name: releases
path: dist

test-built-dist:
name: Test noisepy-seis package
needs: build-artifact
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
name: Install Python
with:
python-version: 3.9
- uses: actions/download-artifact@v3
with:
name: releases
path: dist
- name: List contents of built dist
run: |
ls -ltrh
ls -ltrh dist
- name: Publish to Test PyPI
uses: pypa/[email protected]
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
verbose: true
skip_existing: true
- name: Check pypi packages
id: check_pkg
run: |
sleep 3
python -m pip install --upgrade pip
echo "=== Testing wheel file ==="
# Install wheel to get dependencies and check import
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre noisepy-seis
echo ::set-output name=package-version::$(python -c "import noisepy.seis; print(noisepy.seis.__version__)")
noisepy --help
echo "=== Done testing wheel file ==="
echo "=== Testing source tar file ==="
# Install tar gz and check import
python -m pip uninstall --yes noisepy-seis
python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade --pre --no-binary=:all: noisepy-seis
python -c "import noisepy.seis; print(noisepy.seis.__version__)"
noisepy --help
echo "=== Done testing source tar file ==="
outputs:
package-version: ${{steps.check_pkg.outputs.package-version}}
publish-pypi:
name: Push noisepy-seis to production pypi
needs: test-built-dist
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: releases
path: dist
- name: Publish to PyPI
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}
push_to_registry:
name: Push Docker image to Docker Hub
needs: [publish-pypi, test-built-dist]
runs-on: ubuntu-latest
steps:
- name: Check out the repo
Expand All @@ -37,3 +126,4 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
build-args: VERSION=${{needs.test-built-dist.outputs.package-version}}
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
FROM --platform=$BUILDPLATFORM ubuntu:22.04
FROM --platform=$BUILDPLATFORM ubuntu:20.04

# Avoid timezone prompts during python installation
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y libopenmpi-dev && \
apt-get install -y python3 && \
apt-get install -y python3.8 && \
apt-get install -y python3-pip && \
pip3 install --upgrade pip

RUN pip3 install noisepy-seis
ARG VERSION
RUN pip3 install noisepy-seis==${VERSION}
ENTRYPOINT ["noisepy"]
CMD ["--help"]

0 comments on commit 48a2e39

Please sign in to comment.