diff --git a/.github/workflows/conda-build.yml b/.github/workflows/conda-build.yml index 98baff384..b508429db 100644 --- a/.github/workflows/conda-build.yml +++ b/.github/workflows/conda-build.yml @@ -7,6 +7,8 @@ on: pull_request: branches: - master + release: + types: [published] workflow_dispatch: jobs: @@ -83,8 +85,6 @@ jobs: environment: name: pypi url: https://pypi.org/p/ml-metadata/ - permissions: - id-token: write steps: - name: Retrieve wheels uses: actions/download-artifact@v4.1.8 @@ -100,3 +100,5 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1.9 with: packages_dir: wheels/ + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} diff --git a/README.md b/README.md index b2586734c..4cd4a06b3 100644 --- a/README.md +++ b/README.md @@ -125,3 +125,68 @@ MLMD is built and tested on the following 64-bit operating systems: * Ubuntu 20.04 or later. * [DEPRECATED] Windows 10 or later. For a Windows-compatible library, please refer to MLMD 1.14.0 or earlier versions. + +## Releasing Wheels to PyPI + +### Setup (Required for both release methods) + +Before releasing, you need to set up the PyPI environment and token once: + +**Step 1: Create PyPI environment** + +Create a new environment named `pypi` in the GitHub repository: +- Go to https://github.com/google/ml-metadata/settings/environments/new +- Name it `pypi` +- Click "Configure environment" + +**Step 2: Add PYPI_TOKEN secret** + +Add your PyPI token to the `pypi` environment: +- In the `pypi` environment settings, scroll to "Environment secrets" +- Click "Add secret" +- Name: `PYPI_TOKEN` (use this exact name) +- Value: Your PyPI API token +- Click "Add secret" + +**Step 3: Commit and push your release branch** + +Ensure your release branch has the correct version set in `ml_metadata/version.py`, then: + +```bash +git add ml_metadata/version.py +git commit -m "Prepare release vX.Y.Z" +git push origin your-release-branch +``` + +### Part 1: Releasing via `workflow_dispatch` + +This method allows you to manually trigger a release from any branch without creating a GitHub release. + +**Steps** (after completing setup above): + +1. Navigate to the GitHub Actions page: https://github.com/google/ml-metadata/actions +2. Find and select the `Build ml-metadata with Conda` workflow: https://github.com/google/ml-metadata/actions/workflows/conda-build.yml +3. Click the "Run workflow" dropdown button. +4. Select your release branch from the dropdown menu. +5. Click "Run workflow". + +The workflow will build wheels for all supported Python versions and automatically upload them to PyPI if the token is configured correctly. + +### Part 2: Releasing via GitHub Release + +This method creates a formal GitHub release with a tag, which automatically triggers the build and upload workflow. + +**Steps** (after completing setup above): + +1. Go to the Releases tab: https://github.com/google/ml-metadata/releases +2. Click the `Draft new release` button (you'll be redirected to https://github.com/google/ml-metadata/releases/new) +3. Click the `Select tag` button and create a new tag for your release (e.g., `v1.18.0`) +4. Click the `Target` dropdown and select your release branch +5. Fill in the **Release title** and **Release notes** sections +6. Choose the release type: + - Check `Set as a pre-release` if this is a beta/test release + - Leave unchecked for `Set as the latest release` for stable releases +7. Click the `Publish release` button +8. Verify the workflow is running by going to the Actions tab: https://github.com/google/ml-metadata/actions/workflows/conda-build.yml + +The `Build ml-metadata with Conda` workflow will automatically trigger and build/upload wheels to PyPI if the token is configured correctly. diff --git a/WORKSPACE b/WORKSPACE index 313a86c3e..129a3b712 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -251,9 +251,9 @@ ZETASQL_COMMIT = "ac37cf5c0d80b5605176fc0f29e87b12f00be693" # 08/10/2022 http_archive( name = "com_google_zetasql", urls = ["https://github.com/google/zetasql/archive/%s.zip" % ZETASQL_COMMIT], - strip_prefix = "zetasql-%s" % ZETASQL_COMMIT, + strip_prefix = "googlesql-%s" % ZETASQL_COMMIT, #patches = ["//ml_metadata/third_party:zetasql.patch"], - sha256 = '651a768cd51627f58aa6de7039aba9ddab22f4b0450521169800555269447840' + sha256 = '86f81591ab5ec20457a5394eb2c5c981e6f6c89f4c49c211d096c3acffec1eb1' ) load("@com_google_zetasql//bazel:zetasql_deps_step_1.bzl", "zetasql_deps_step_1")