Skip to content

Commit 9a26b7e

Browse files
committed
First wheel release, then create the GitHub release, and remove code
duplication
1 parent cc0a43e commit 9a26b7e

File tree

5 files changed

+130
-144
lines changed

5 files changed

+130
-144
lines changed

.github/workflows/publish_docker.yml

Lines changed: 123 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Build and Publish Docker Container and Pypanda Docs # Only for main panda-re repo, not forks
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches:
67
- dev
@@ -11,23 +12,27 @@ env:
1112

1213
jobs:
1314
create_release:
14-
if: github.repository == 'panda-re/panda' && github.ref == 'refs/heads/dev'
15+
name: Create next release version
16+
if: github.repository == 'panda-re/panda'
1517
runs-on: panda-arc
1618
outputs:
1719
v-version: ${{ steps.version.outputs.v-version }}
1820
steps:
1921
- name: Install git
20-
run: sudo apt-get -qq update -y && sudo apt-get -qq install git curl jq -y
22+
run: |
23+
sudo apt-get -qq update -y
24+
sudo apt-get -qq install git curl jq -y
2125
- name: Get next version
22-
uses: reecetech/version-increment@2023.10.2
26+
uses: reecetech/version-increment@2024.10.1
2327
id: version
2428
with:
2529
release_branch: dev
2630
use_api: true
2731

2832
build_release_assets:
29-
if: github.repository == 'panda-re/panda' && github.ref == 'refs/heads/dev'
30-
needs: create_release
33+
name: Create Panda Debian package and wheel
34+
if: github.repository == 'panda-re/panda'
35+
needs: [ create_release ]
3136
runs-on: panda-arc
3237
strategy:
3338
matrix:
@@ -37,7 +42,9 @@ jobs:
3742

3843
steps:
3944
- name: Install git
40-
run: sudo apt-get -qq update -y && sudo apt-get -qq install git curl jq -y
45+
run: |
46+
sudo apt-get -qq update -y
47+
sudo apt-get -qq install git curl jq -y
4148
4249
- name: Check out
4350
uses: actions/checkout@v4
@@ -48,42 +55,93 @@ jobs:
4855
working-directory: panda/debian
4956
run: ./setup.sh Ubuntu ${{ matrix.ubuntu_version }}
5057

51-
- name: Upload wheel and debian packages to release
52-
uses: softprops/action-gh-release@v2
53-
env:
54-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55-
with:
56-
tag_name: ${{ needs.create_release.outputs.v-version }}
57-
files: |
58-
panda/debian/pandare*.whl
59-
panda/debian/pandare*.deb
60-
6158
- name: Store the PyPanda distribution packages
6259
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
6360
uses: actions/upload-artifact@v4
6461
with:
6562
name: pypanda
6663
path: panda/debian/pandare*.whl
6764
if-no-files-found: error
68-
69-
- name: 'Login to Docker Registry'
70-
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
65+
retention-days: 7
66+
67+
- name: Store the Panda Debian packages
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: panda-debian
71+
path: panda/debian/pandare*.deb
72+
if-no-files-found: error
73+
retention-days: 7
74+
75+
publish_to_pypi_and_release:
76+
name: Publish Python 🐍 distribution 📦 to PyPI and Create Release
77+
if: github.repository == 'panda-re/panda'
78+
needs: [ create_release, build_release_assets ]
79+
runs-on: ubuntu-latest
80+
environment:
81+
name: pypi
82+
url: https://pypi.org/p/pandare # Replace <package-name> with your PyPI project name
83+
permissions:
84+
id-token: write # IMPORTANT: mandatory for trusted publishing
85+
contents: write # Required for creating releases
86+
steps:
87+
- name: Download PyPanda
88+
uses: actions/download-artifact@v4
89+
with:
90+
name: pypanda
91+
path: dist/
92+
93+
- name: Publish distribution 📦 to PyPI
94+
uses: pypa/gh-action-pypi-publish@release/v1
95+
with:
96+
verbose: true
97+
98+
- name: Download Panda Debian Packages
99+
uses: actions/download-artifact@v4
100+
with:
101+
name: panda-debian
102+
path: debian/
103+
104+
- name: Upload wheel and debian packages to release
105+
uses: softprops/action-gh-release@v2
106+
env:
107+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
with:
109+
tag_name: ${{ needs.create_release.outputs.v-version }}
110+
files: |
111+
dist/pandare*.whl
112+
debian/pandare*.deb
113+
114+
upload_containers:
115+
name: Build and push PANDA Docker containers
116+
if: github.repository == 'panda-re/panda'
117+
needs: [ create_release, publish_to_pypi_and_release ]
118+
runs-on: panda-arc
119+
steps:
120+
- name: Check out
121+
uses: actions/checkout@v4
122+
with:
123+
fetch-depth: 0
124+
125+
- name: Login to Docker Registry
71126
uses: docker/login-action@v3
72127
with:
73128
username: pandare
74129
password: ${{secrets.pandare_dockerhub}}
75-
76-
77-
#- name: 'Login to GHCR Registry'
78-
# if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
79-
# uses: docker/login-action@v3
80-
# with:
81-
# registry: ghcr.io
82-
# username: ${{ github.repository_owner }}
83-
# password: ${{ secrets.GITHUB_TOKEN }}
130+
131+
- name: Build pandadev:latest
132+
uses: docker/build-push-action@v5
133+
with:
134+
push: true
135+
context: ${{ github.workspace }}
136+
tags: |
137+
pandare/pandadev:${{ github.sha }}
138+
pandare/pandadev:${{ needs.create_release.outputs.v-version }}
139+
pandare/pandadev:latest
140+
target: developer
141+
cache-from: type=registry,ref=pandare/pandadev:cache
142+
cache-to: type=registry,ref=pandare/pandadev:cache,mode=max
84143

85144
- name: Build panda:latest
86-
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
87145
uses: docker/build-push-action@v5
88146
with:
89147
push: true
@@ -92,119 +150,48 @@ jobs:
92150
pandare/panda:${{ github.sha }}
93151
pandare/panda:${{ needs.create_release.outputs.v-version }}
94152
pandare/panda:latest
95-
# ghcr.io/pandare/panda:${{ github.sha }}
96-
# ghcr.io/pandare/panda:${{ needs.create_release.outputs.v-version }}
97-
# ghcr.io/pandare/panda:latest
98153
target: panda
99-
- name: Build pandadev:latest
100-
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
154+
cache-from: type=registry,ref=pandare/pandadev:cache
155+
cache-to: type=registry,ref=pandare/panda:cache,mode=max
156+
157+
- name: Build Panda stable container
158+
if: github.ref_name == 'stable'
101159
uses: docker/build-push-action@v5
102160
with:
103161
push: true
104162
context: ${{ github.workspace }}
105163
tags: |
106-
pandare/pandadev:${{ github.sha }}
107-
pandare/pandadev:${{ needs.create_release.outputs.v-version }}
108-
pandare/pandadev:latest
109-
# ghcr.io/pandare/pandadev:${{ github.sha }}
110-
# ghcr.io/pandare/pandadev:${{ needs.create_release.outputs.v-version }}
111-
# ghcr.io/pandare/pandadev:latest
112-
target: developer
164+
pandare/panda_stable:${{ github.sha }}
165+
pandare/panda_stable:${{ needs.create_release.outputs.v-version }}
166+
pandare/panda_stable:latest
167+
target: panda
168+
cache-from: type=registry,ref=pandare/panda:cache
169+
cache-to: type=registry,ref=pandare/panda_stable:cache,mode=max
170+
113171
- name: Checkout docs and reset
114-
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
115-
run: rm -rf "${GITHUB_WORKSPACE}/auto_pydoc";
116-
git clone https://panda-jenkins-ci:${{ secrets.PANDABOT_GITHUB_API }}@github.com/panda-re/panda-re.github.io.git --branch=master ${GITHUB_WORKSPACE}/auto_pydoc/pandare
117-
- name: Update PYPANDA docs in container
118-
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
119-
run: docker run --rm -v ${GITHUB_WORKSPACE}/auto_pydoc:/out pandare/pandadev:latest /bin/sh -c "pip3 install pdoc3==0.10.0; cd /panda/panda/python/core; pdoc3 --html --template-dir=../docs/template --force -o /out/${GITHUB_REF##*/} pandare; chmod -R 777 /out/"
120-
# will put docs in workspace/auto_pydoc/dev/pandare and/or workspace/auto_pydoc/stable/pandare
121-
# we want to copy auto_pydoc/dev/pandare to auto_pydoc/pandare/ and /auto_pydoc/stable/pandare to /auto_pydoc/pandare/stable
122-
#
123-
# This is a bit complicated, sorry. We want to keep pandare/{CNAME,.git/} and nothing else
124-
# then we copy in the new files (and merge doc-search.html and index.js with dev/pandare/
125-
- name: Push PYPANDA docs to GitHub Pages if docs changed
126-
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
127-
run: cd "${GITHUB_WORKSPACE}/auto_pydoc" &&
128-
mv pandare/CNAME dev &&
129-
rm -rf pandare/* &&
130-
mv dev/pandare/* pandare &&
131-
rmdir dev/pandare &&
132-
mv dev/* pandare/ &&
133-
cd pandare &&
134-
git config --global user.email "panda-ci@panda-re.mit.edu" &&
135-
git config --global user.name "PANDA Bot" &&
136-
git add . &&
137-
git commit -m "Documentation update for PANDA commit ${{ github.sha }} branch dev" &&
138-
git push || true
172+
run: |
173+
rm -rf "${GITHUB_WORKSPACE}/auto_pydoc";
174+
git clone https://panda-jenkins-ci:${{ secrets.PANDABOT_GITHUB_API }}@github.com/panda-re/panda-re.github.io.git --branch=master ${GITHUB_WORKSPACE}/auto_pydoc/pandare
139175
140-
publish-to-pypi:
141-
name: Publish Python 🐍 distribution 📦 to PyPI
142-
if: github.repository == 'panda-re/panda' && github.ref == 'refs/heads/dev'
143-
needs:
144-
- build_release_assets
145-
runs-on: ubuntu-latest
146-
environment:
147-
name: pypi
148-
url: https://pypi.org/p/pandare # Replace <package-name> with your PyPI project name
149-
permissions:
150-
id-token: write # IMPORTANT: mandatory for trusted publishing
151-
152-
steps:
153-
- name: Download all the dists
154-
uses: actions/download-artifact@v4
155-
with:
156-
name: pypanda
157-
path: dist/
158-
159-
- name: Publish distribution 📦 to PyPI
160-
uses: pypa/gh-action-pypi-publish@release/v1
161-
with:
162-
verbose: true
163-
164-
build_stable:
165-
if: github.repository == 'panda-re/panda' && github.ref == 'refs/heads/stable'
166-
runs-on: panda-arc
167-
steps:
168-
- name: Checkout PANDA at current commit
169-
uses: actions/checkout@v4
170-
171-
- name: 'Login to Docker Registry'
172-
uses: docker/login-action@v3
173-
with:
174-
username: pandare
175-
password: ${{secrets.pandare_dockerhub}}
176-
177-
- name: Build Bionic container
178-
# Push both dev and regular container
179-
uses: docker/build-push-action@v5
180-
with:
181-
push: true
182-
context: ${{ github.workspace }}
183-
tags: |
184-
pandare/panda_stable:${{ github.sha }}
185-
pandare/panda_stable:latest
186-
target: panda
187-
188-
- name: Checkout docs and reset
189-
run: rm -rf "${GITHUB_WORKSPACE}/auto_pydoc";
190-
git clone https://panda-jenkins-ci:${{ secrets.PANDABOT_GITHUB_API }}@github.com/panda-re/panda-re.github.io.git --branch=master ${GITHUB_WORKSPACE}/auto_pydoc/pandare
191-
192-
- name: Update PYPANDA docs in container
193-
run: docker run --rm -v ${GITHUB_WORKSPACE}/auto_pydoc/pandare:/out pandare/pandadev:latest /bin/sh -c "pip3 install pdoc3==0.10.0; cd /panda/panda/python/core; pdoc3 --html --template-dir=../docs/template --force -o /out/${GITHUB_REF##*/} pandare; chmod -R 777 /out/"
194-
# will put docs in workspace/auto_pydoc/dev/pandare and/or workspace/auto_pydoc/stable/pandare
195-
# we want to copy /auto_pydoc/dev/pandare to /auto_doc and /auto_pydoc/stable/pandare to /auto_pydoc/stable
176+
- name: Update PYPANDA docs in container
177+
run: docker run --rm -v ${GITHUB_WORKSPACE}/auto_pydoc/pandare:/out pandare/pandadev:latest /bin/sh -c "pip3 install pdoc3==0.10.0; cd /panda/panda/python/core; pdoc3 --html --template-dir=../docs/template --force -o /out/${GITHUB_REF##*/} pandare; chmod -R 777 /out/"
178+
179+
# will put docs in workspace/auto_pydoc/{dev, stable}/pandare and/or workspace/auto_pydoc/stable/pandare
180+
# we want to copy auto_pydoc/{dev, stable}/pandare to auto_pydoc/pandare/ and /auto_pydoc/stable/pandare to /auto_pydoc/pandare/stable
196181
#
197-
# This is a bit complicated, sorry. We create a directory stable and combine doc-search.html and index.js in there.
198-
- name: Push PYPANDA docs to GitHub Pages if docs changed
199-
#run: cd "${GITHUB_WORKSPACE}/auto_pydoc/pandare" && mv ./stable ./stable2; mv ./stable2/pandare stable; rm -rf ./stable2;
200-
run: cd "${GITHUB_WORKSPACE}/auto_pydoc" &&
201-
rm -rf pandare/stable &&
202-
mv stable/pandare/* pandare/stable &&
203-
rmdir stable/pandare &&
204-
mv stable/* pandare/stable &&
205-
cd pandare &&
206-
git config --global user.email "panda-ci@panda-re.mit.edu" &&
207-
git config --global user.name "PANDA Bot" &&
208-
git add . &&
209-
git commit -m "Documentation update for PANDA commit ${{ github.sha }} branch stable" &&
210-
git push || true
182+
# This is a bit complicated, sorry. We want to keep pandare/{CNAME,.git/} and nothing else
183+
# then we copy in the new files (and merge doc-search.html and index.js with {dev, stable}/pandare/
184+
- name: Push PYPANDA docs to GitHub Pages if docs changed
185+
run: |
186+
cd "${GITHUB_WORKSPACE}/auto_pydoc"
187+
mv pandare/CNAME ${{ github.ref_name }}
188+
rm -rf pandare/*
189+
mv ${{ github.ref_name }}/pandare/* pandare
190+
rmdir ${{ github.ref_name }}/pandare
191+
mv ${{ github.ref_name }}/* pandare/
192+
cd pandare
193+
git config --global user.email "panda-ci@panda-re.mit.edu"
194+
git config --global user.name "PANDA Bot"
195+
git add .
196+
git commit -m "Documentation update for PANDA commit ${{ github.sha }} branch ${{ github.ref_name }}"
197+
git push || true

panda/debian/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
panda.deb
1+
*.deb
2+
*.whl

panda/python/core/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ data
88
a
99
__pycache__
1010
*.egg-info
11+
.eggs/

panda/python/core/pyproject.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,3 @@ dependencies = [
3636
"protobuf>=4.25.1",
3737
"colorama"
3838
]
39-
40-
[tool.setuptools_scm]
41-
root = "../../.."
42-
fallback_version = "0.0.0.1"
43-
version_scheme = "guess-next-dev"
44-
local_scheme = "no-local-version"

panda/python/core/setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
else:
1010
from setuptools_scm import get_version
1111
version = get_version(root='../../..',
12-
fallback_version="0.0.0.1",
12+
fallback_version="0.0.1",
1313
version_scheme="guess-next-dev",
1414
local_scheme="no-local-version")
15+
# python3 -m setuptools_scm -r .. --strip-dev is implemented here
16+
# https://github.com/pypa/setuptools-scm/blob/62ae6400205533fb4b355170a11295e49b366d23/src/setuptools_scm/_cli.py#L42-L43
17+
version = version.partition(".dev")[0]
1518

1619
with open("README.md", "r") as fh:
1720
long_description = fh.read()

0 commit comments

Comments
 (0)