Skip to content

add drop Gop on PsetTable #83

add drop Gop on PsetTable

add drop Gop on PsetTable #83

Workflow file for this run

name: Publish to PyPI
on:
push:
branches: [ main, master ]
workflow_dispatch:
permissions:
contents: read
jobs:
check:
name: Check version on PyPI
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get.outputs.version }}
should_publish: ${{ steps.get.outputs.should_publish }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Determine version and publish necessity
id: get
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const toml = fs.readFileSync('src/bsdd_json/pyproject.toml', 'utf8');
const verMatch = toml.match(/^version\s*=\s*"([^"]+)"/m);
if (!verMatch) {
core.setFailed('Could not parse version from pyproject.toml');
return;
}
const nameMatch = toml.match(/^name\s*=\s*"([^"]+)"/m);
const pkgName = nameMatch ? nameMatch[1] : 'bsdd_json';
const version = verMatch[1];
core.setOutput('version', version);
const url = `https://pypi.org/pypi/${pkgName}/json`;
try {
const res = await fetch(url);
if (!res.ok) {
core.info(`Package ${pkgName} not found on PyPI; will publish.`);
core.setOutput('should_publish', 'true');
} else {
const data = await res.json();
const exists = data && data.releases && Object.prototype.hasOwnProperty.call(data.releases, version);
core.info(`PyPI ${pkgName} versions: ${Object.keys(data.releases).slice(-5).join(', ')} ...`);
core.setOutput('should_publish', exists ? 'false' : 'true');
}
} catch (e) {
core.warning(`Failed to query PyPI API: ${e}. Proceeding to publish.`);
core.setOutput('should_publish', 'true');
}
build_publish:
name: Build and Publish
needs: check
if: needs.check.outputs.should_publish == 'true'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/bsdd_json
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build backend
run: |
python -m pip install --upgrade pip
pip install build
- name: Build sdist and wheel (bsdd_json)
working-directory: src/bsdd_json
run: |
python -m build
- name: Publish to PyPI via OIDC
uses: pypa/gh-action-pypi-publish@release/v1
with:
# Uses GitHub OIDC automatically (no password input required)
# Point to the dist/ created in src/bsdd_json
packages-dir: src/bsdd_json/dist/