From 398eb9a91e06e85b830fdf784e52aeb795daa2a2 Mon Sep 17 00:00:00 2001 From: Michael Johansen Date: Mon, 15 Sep 2025 16:33:08 -0500 Subject: [PATCH 1/2] Add the publish workflow Signed-off-by: Michael Johansen --- .github/workflows/publish.yml | 98 +++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..06a5e0c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,98 @@ +name: Publish ni.datastore + +on: + release: + types: [published] + workflow_dispatch: + inputs: + environment: + description: The environment to publish to. + default: 'none' + required: true + type: choice + options: + - none + - pypi + - testpypi + +env: + dist-artifact-name: ni.datastore-distribution-packages + environment: ${{ github.event_name == 'release' && 'pypi' || inputs.environment }} + environment-info: | + { + "pypi": { + "base-url": "https://pypi.org", + "upload-url": "https://upload.pypi.org/legacy/" + }, + "testpypi": { + "base-url": "https://test.pypi.org", + "upload-url": "https://test.pypi.org/legacy/" + } + } + +jobs: + check_ni_datastore: + name: Check ni.datastore + uses: ./.github/workflows/check_ni_datastore.yml + check_docs: + name: Check docs + uses: ./.github/workflows/check_docs.yml + build_ni_datastore: + name: Build ni.datastore + runs-on: ubuntu-latest + needs: [check_ni_datastore, check_docs] + steps: + - name: Check out repo + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - name: Set up Python + uses: ni/python-actions/setup-python@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 + - name: Set up Poetry + uses: ni/python-actions/setup-poetry@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 + - name: Check project version + if: github.event_name == 'release' + uses: ni/python-actions/check-project-version@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 + - name: Build distribution packages + run: poetry build + - name: Upload build artifacts + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: ${{ env.dist-artifact-name }} + path: dist/* + publish_to_pypi: + name: Publish ni.datastore to PyPI + if: github.event_name == 'release' || inputs.environment != 'none' + runs-on: ubuntu-latest + needs: [build_ni_datastore] + environment: + # This logic is duplicated because `name` doesn't support the `env` context. + name: ${{ github.event_name == 'release' && 'pypi' || inputs.environment }} + url: ${{ fromJson(env.environment-info)[env.environment].base-url }}/p/ni.datastore + permissions: + id-token: write + steps: + - name: Download build artifacts + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + name: ${{ env.dist-artifact-name }} + path: dist/ + - run: ls -lR + - name: Upload to ${{ env.environment }} + uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 + with: + repository-url: ${{ fromJson(env.environment-info)[env.environment].upload-url }} + update_version: + name: Update ni.datastore version + runs-on: ubuntu-latest + needs: [build_ni_datastore] + permissions: + contents: write + pull-requests: write + steps: + - name: Check out repo + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - name: Set up Python + uses: ni/python-actions/setup-python@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 + - name: Set up Poetry + uses: ni/python-actions/setup-poetry@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 + - name: Update project version + uses: ni/python-actions/update-project-version@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 \ No newline at end of file From b22fd9c7c07b6268a1d3bb4d782920e92b8059b4 Mon Sep 17 00:00:00 2001 From: Michael Johansen Date: Tue, 16 Sep 2025 09:55:44 -0500 Subject: [PATCH 2/2] Add a publishing section in CONTRIBUTING.md Signed-off-by: Michael Johansen --- CONTRIBUTING.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 118342e..4977913 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,6 +27,28 @@ See [GitHub's official documentation](https://help.github.com/articles/using-pul - TODO: include testing steps here. +# Publishing on PyPI + +You can publish the ni.datastore package by creating a GitHub release +in the datastore-python repo. Here are the steps to follow to publish the package: + +1. From the main GitHub repo page, select "Create a new release". +2. On the "New Release" page, create a new tag using the "Select Tag" drop down. The tag must be the package version, matching the +value found in pyproject.toml. Example: `0.1.0-dev0`. +3. Enter a title in the "Release title" field. The title should contain the package name and +version in the format `ni.datastore `. For example: `ni.datastore 0.1.0-dev0`. +4. Click "Generate release notes" and edit the release notes. + - Delete entries for PRs that do not affect users, such as "chore(deps):" and "fix(deps):" PRs. + - Consider grouping related entries. + - Reformat entries to be more readable. For example, change "Blah blah by so-and-so in \#123" to "Blah blah (\#123)". +5. If this is a pre-release release, check the "Set as a pre-release" checkbox. +6. Click "Publish release". +7. Creating a release will start the publish workflow. You can track the +progress of this workflow in the "Actions" page of the GitHub repo. +8. The workflow job that publishes a package to pypi requires code owner approval. This job will automatically send code owners a notification email, then it will wait for them to log in and approve the deployment. +9. After receiving code owner approval, the publish workflow will resume. +10. Once the publish workflow has finished, you should see your release on pypi. + # Developer Certificate of Origin (DCO) Developer's Certificate of Origin 1.1