|
| 1 | +name: Publish nidaqmx |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + environment: |
| 9 | + description: The environment to publish to. |
| 10 | + default: 'none' |
| 11 | + required: true |
| 12 | + type: choice |
| 13 | + options: |
| 14 | + - none |
| 15 | + - pypi |
| 16 | + - testpypi |
| 17 | + |
| 18 | +env: |
| 19 | + dist-artifact-name: nidaqmx-distribution-packages |
| 20 | + environment: ${{ github.event_name == 'release' && 'pypi' || inputs.environment }} |
| 21 | + environment-info: | |
| 22 | + { |
| 23 | + "pypi": { |
| 24 | + "base-url": "https://pypi.org", |
| 25 | + "upload-url": "https://upload.pypi.org/legacy/" |
| 26 | + }, |
| 27 | + "testpypi": { |
| 28 | + "base-url": "https://test.pypi.org", |
| 29 | + "upload-url": "https://test.pypi.org/legacy/" |
| 30 | + } |
| 31 | + } |
| 32 | +
|
| 33 | +jobs: |
| 34 | + check_nidaqmx: |
| 35 | + name: Check nidaqmx |
| 36 | + uses: ./.github/workflows/build.yml |
| 37 | + check_docs: |
| 38 | + name: Check docs |
| 39 | + uses: ./.github/workflows/generate_docs.yml |
| 40 | + build_nidaqmx: |
| 41 | + name: Build nidaqmx |
| 42 | + runs-on: ubuntu-latest |
| 43 | + needs: [check_nidaqmx, check_docs] |
| 44 | + steps: |
| 45 | + - name: Check out repo |
| 46 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 47 | + - name: Set up Python |
| 48 | + uses: ni/python-actions/setup-python@e8f25e9a64426bd431ac124b83df11b76cdf60d5 # v0.1.0 |
| 49 | + - name: Set up Poetry |
| 50 | + uses: ni/python-actions/setup-poetry@e8f25e9a64426bd431ac124b83df11b76cdf60d5 # v0.1.0 |
| 51 | + - name: Check project version |
| 52 | + if: github.event_name == 'release' |
| 53 | + uses: ni/python-actions/check-project-version@275868c1620d0343a006472f6300bd80f76bbd92 # users/bkeryan/update-project-version |
| 54 | + - name: Build distribution packages |
| 55 | + run: poetry build |
| 56 | + - name: Upload build artifacts |
| 57 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 58 | + with: |
| 59 | + name: ${{ env.dist-artifact-name }} |
| 60 | + path: dist/* |
| 61 | + publish_to_pypi: |
| 62 | + name: Publish nidaqmx to PyPI |
| 63 | + if: github.event_name == 'release' || inputs.environment != 'none' |
| 64 | + runs-on: ubuntu-latest |
| 65 | + needs: [build_nidaqmx] |
| 66 | + environment: |
| 67 | + # This logic is duplicated because `name` doesn't support the `env` context. |
| 68 | + name: ${{ github.event_name == 'release' && 'pypi' || inputs.environment }} |
| 69 | + url: ${{ fromJson(env.environment-info)[env.environment].base-url }}/p/nidaqmx |
| 70 | + permissions: |
| 71 | + id-token: write |
| 72 | + steps: |
| 73 | + - name: Download build artifacts |
| 74 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 75 | + with: |
| 76 | + name: ${{ env.dist-artifact-name }} |
| 77 | + path: dist/ |
| 78 | + - run: ls -lR |
| 79 | + - name: Upload to ${{ env.environment }} |
| 80 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 81 | + with: |
| 82 | + repository-url: ${{ fromJson(env.environment-info)[env.environment].upload-url }} |
| 83 | + update_version: |
| 84 | + name: Update nidaqmx version |
| 85 | + runs-on: ubuntu-latest |
| 86 | + needs: [build_nidaqmx] |
| 87 | + permissions: |
| 88 | + contents: write |
| 89 | + pull-requests: write |
| 90 | + steps: |
| 91 | + - name: Check out repo |
| 92 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 93 | + - name: Set up Python |
| 94 | + uses: ni/python-actions/setup-python@e8f25e9a64426bd431ac124b83df11b76cdf60d5 # v0.1.0 |
| 95 | + - name: Set up Poetry |
| 96 | + uses: ni/python-actions/setup-poetry@e8f25e9a64426bd431ac124b83df11b76cdf60d5 # v0.1.0 |
| 97 | + - name: Update project version |
| 98 | + uses: ni/python-actions/update-project-version@275868c1620d0343a006472f6300bd80f76bbd92 # users/bkeryan/update-project-version |
0 commit comments