Skip to content

Commit 31faef3

Browse files
authored
Add publish workflow (#147)
1 parent 45f0e3d commit 31faef3

File tree

2 files changed

+99
-1
lines changed

2 files changed

+99
-1
lines changed

.github/workflows/publish.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Publish nipanel
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: nipanel-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_nipanel:
35+
name: Check nipanel
36+
uses: ./.github/workflows/check_nipanel.yml
37+
check_docs:
38+
name: Check docs
39+
uses: ./.github/workflows/check_docs.yml
40+
build_nipanel:
41+
name: Build nipanel
42+
runs-on: ubuntu-latest
43+
needs: [check_nipanel, check_docs]
44+
steps:
45+
- name: Check out repo
46+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
47+
- name: Set up Python
48+
uses: ni/python-actions/setup-python@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0
49+
- name: Set up Poetry
50+
uses: ni/python-actions/setup-poetry@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0
51+
- name: Check project version
52+
if: github.event_name == 'release'
53+
uses: ni/python-actions/check-project-version@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0
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 nipanel to PyPI
63+
if: github.event_name == 'release' || inputs.environment != 'none'
64+
runs-on: ubuntu-latest
65+
needs: [build_nipanel]
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/nipanel
70+
permissions:
71+
id-token: write
72+
steps:
73+
- name: Download build artifacts
74+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.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@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
81+
with:
82+
repository-url: ${{ fromJson(env.environment-info)[env.environment].upload-url }}
83+
update_version:
84+
name: Update nipanel version
85+
runs-on: ubuntu-latest
86+
needs: [build_nipanel]
87+
permissions:
88+
contents: write
89+
pull-requests: write
90+
steps:
91+
- name: Check out repo
92+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
93+
- name: Set up Python
94+
uses: ni/python-actions/setup-python@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0
95+
- name: Set up Poetry
96+
uses: ni/python-actions/setup-poetry@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0
97+
- name: Update project version
98+
uses: ni/python-actions/update-project-version@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "nipanel"
3-
version = "0.1.0"
3+
version = "0.1.0-dev0"
44
description = "NI Panel Python API"
55
authors = [{name = "NI", email = "[email protected]"}]
66
readme = "README.md"

0 commit comments

Comments
 (0)