Skip to content

fix publish workflow #28

fix publish workflow

fix publish workflow #28

Workflow file for this run

name: Publish to PyPI
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [published]
jobs:
# Build a pure Python wheel and upload as an artifact
build-wheel:
runs-on: ubuntu-latest
steps:
- name: Setup jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Checkout code
uses: actions/checkout@v4
with:
path: refl1d
- name: Get latest bumps release tag
id: latest_release
run: |
RELEASE_TAG=$(curl -s https://api.github.com/repos/bumps/bumps/releases/latest | jq -r '.tag_name')
echo "BUMPS_RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
- name: Checkout tools repo
uses: actions/checkout@v4
with:
repository: bumps/bumps
ref: ${{ steps.latest_release.outputs.BUMPS_RELEASE_TAG }}
path: bumps
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: actions/setup-node@v4
with:
node-version: 20
- name: build bumps webview
run: |
cd bumps/bumps/webview/client
npm install
npm link
- name: build refl1d webview
run: |
cd refl1d/refl1d/webview/client
npm install
npm link bumps-webview-client
npm run build_prod
npm pack
- name: Install dependencies for building the wheel
run: |
python -m pip install --upgrade pip build
python -m pip install -e ./refl1d[dev]
- name: Create the wheel
run: python -m build refl1d
- name: Upload the wheel artifact
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
refl1d/dist/refl1d-*-py3-none-any.whl
refl1d/refl1d/webview/client/*.tgz
publish:
needs: build-wheel
runs-on: ubuntu-latest
steps:
- name: Retrieve all artifacts
uses: actions/download-artifact@v4
- name: show files
run: |
ls -R artifacts
echo "SRC_DIST=$(ls artifacts/dist/*.tar.gz)" >> $GITHUB_ENV
echo "PY3_WHL=$(ls artifacts/dist/*.whl)" >> $GITHUB_ENV
- name: Update current release
if: startsWith(github.ref, 'refs/tags')
uses: johnwbyrd/update-release@v1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
${{ env.PY3_WHL }}
- name: publish distribution to Test PyPI
env:
TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
if: env.TEST_PYPI_API_TOKEN != null
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
packages-dir: artifacts/dist/
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: artifacts/dist/