Publish to PyPI #8
This file contains hidden or 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: Publish to PyPI | |
| on: | |
| release: | |
| types: [released] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to publish (e.g., v0.0.1)' | |
| required: true | |
| type: string | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| build-dist: | |
| name: Build distribution | |
| permissions: | |
| contents: read | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.event.inputs.tag || github.ref }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: Verify version matches tag | |
| run: | | |
| if [ -n "${{ github.event.inputs.tag }}" ]; then | |
| TAG="${{ github.event.inputs.tag }}" | |
| TAG_VERSION=${TAG#v} | |
| else | |
| TAG=${GITHUB_REF#refs/tags/} | |
| TAG_VERSION=${TAG#v} | |
| fi | |
| TOML_VERSION=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") | |
| if [ "$TAG_VERSION" != "$TOML_VERSION" ]; then | |
| echo "Error: Tag version ($TAG_VERSION) does not match pyproject.toml version ($TOML_VERSION)" | |
| exit 1 | |
| fi | |
| echo "Version check passed: $TAG_VERSION" | |
| - name: Build distribution | |
| run: | | |
| # uv build fails with conflicting torch indexes, so use build directly | |
| python3 -m pip install --upgrade build | |
| python3 -m build | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| pypi-publish: | |
| name: Publish to PyPI | |
| needs: build-dist | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/olmoearth-pretrain-minimal | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |