Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <package-version>`. 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
Expand Down
Loading