Skip to content

Upgrade deploy #1560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
259 changes: 123 additions & 136 deletions .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build and Publish Docker Container and Pypanda Docs # Only for main panda-re repo, not forks

on:
workflow_dispatch:
push:
branches:
- dev
Expand All @@ -11,23 +12,27 @@ env:

jobs:
create_release:
if: github.repository == 'panda-re/panda' && github.ref == 'refs/heads/dev'
name: Create next release version
if: github.repository == 'panda-re/panda'
runs-on: panda-arc
outputs:
v-version: ${{ steps.version.outputs.v-version }}
steps:
- name: Install git
run: sudo apt-get -qq update -y && sudo apt-get -qq install git curl jq -y
run: |
sudo apt-get -qq update -y
sudo apt-get -qq install git curl jq -y
- name: Get next version
uses: reecetech/version-increment@2023.10.2
uses: reecetech/version-increment@2024.10.1
id: version
with:
release_branch: dev
use_api: true

build_release_assets:
if: github.repository == 'panda-re/panda' && github.ref == 'refs/heads/dev'
needs: create_release
name: Create Panda Debian package and wheel
if: github.repository == 'panda-re/panda'
needs: [ create_release ]
runs-on: panda-arc
strategy:
matrix:
Expand All @@ -37,7 +42,9 @@ jobs:

steps:
- name: Install git
run: sudo apt-get -qq update -y && sudo apt-get -qq install git curl jq -y
run: |
sudo apt-get -qq update -y
sudo apt-get -qq install git curl jq -y

- name: Check out
uses: actions/checkout@v4
Expand All @@ -48,42 +55,93 @@ jobs:
working-directory: panda/debian
run: ./setup.sh Ubuntu ${{ matrix.ubuntu_version }}

- name: Upload wheel and debian packages to release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create_release.outputs.v-version }}
files: |
panda/debian/pandare*.whl
panda/debian/pandare*.deb

- name: Store the PyPanda distribution packages
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
uses: actions/upload-artifact@v4
with:
name: pypanda
path: panda/debian/pandare*.whl
if-no-files-found: error

- name: 'Login to Docker Registry'
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
retention-days: 7

- name: Store the Panda Debian packages
uses: actions/upload-artifact@v4
with:
name: panda-debian
path: panda/debian/pandare*.deb
if-no-files-found: error
retention-days: 7

publish_to_pypi_and_release:
name: Publish Python 🐍 distribution 📦 to PyPI and Create Release
if: github.repository == 'panda-re/panda'
needs: [ create_release, build_release_assets ]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pandare # Replace <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
contents: write # Required for creating releases
steps:
- name: Download PyPanda
uses: actions/download-artifact@v4
with:
name: pypanda
path: dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true

- name: Download Panda Debian Packages
uses: actions/download-artifact@v4
with:
name: panda-debian
path: debian/

- name: Upload wheel and debian packages to release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create_release.outputs.v-version }}
files: |
dist/pandare*.whl
debian/pandare*.deb

upload_containers:
name: Build and push PANDA Docker containers
if: github.repository == 'panda-re/panda'
needs: [ create_release, publish_to_pypi_and_release ]
runs-on: panda-arc
steps:
- name: Check out
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Login to Docker Registry
uses: docker/login-action@v3
with:
username: pandare
password: ${{secrets.pandare_dockerhub}}


#- name: 'Login to GHCR Registry'
# if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}

- name: Build pandadev:latest
uses: docker/build-push-action@v5
with:
push: true
context: ${{ github.workspace }}
tags: |
pandare/pandadev:${{ github.sha }}
pandare/pandadev:${{ needs.create_release.outputs.v-version }}
pandare/pandadev:latest
target: developer
cache-from: type=registry,ref=pandare/pandadev:cache
cache-to: type=registry,ref=pandare/pandadev:cache,mode=max

- name: Build panda:latest
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
uses: docker/build-push-action@v5
with:
push: true
Expand All @@ -92,119 +150,48 @@ jobs:
pandare/panda:${{ github.sha }}
pandare/panda:${{ needs.create_release.outputs.v-version }}
pandare/panda:latest
# ghcr.io/pandare/panda:${{ github.sha }}
# ghcr.io/pandare/panda:${{ needs.create_release.outputs.v-version }}
# ghcr.io/pandare/panda:latest
target: panda
- name: Build pandadev:latest
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
cache-from: type=registry,ref=pandare/pandadev:cache
cache-to: type=registry,ref=pandare/panda:cache,mode=max

- name: Build Panda stable container
if: github.ref_name == 'stable'
uses: docker/build-push-action@v5
with:
push: true
context: ${{ github.workspace }}
tags: |
pandare/pandadev:${{ github.sha }}
pandare/pandadev:${{ needs.create_release.outputs.v-version }}
pandare/pandadev:latest
# ghcr.io/pandare/pandadev:${{ github.sha }}
# ghcr.io/pandare/pandadev:${{ needs.create_release.outputs.v-version }}
# ghcr.io/pandare/pandadev:latest
target: developer
pandare/panda_stable:${{ github.sha }}
pandare/panda_stable:${{ needs.create_release.outputs.v-version }}
pandare/panda_stable:latest
target: panda
cache-from: type=registry,ref=pandare/panda:cache
cache-to: type=registry,ref=pandare/panda_stable:cache,mode=max

- name: Checkout docs and reset
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
run: rm -rf "${GITHUB_WORKSPACE}/auto_pydoc";
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
- name: Update PYPANDA docs in container
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
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/"
# will put docs in workspace/auto_pydoc/dev/pandare and/or workspace/auto_pydoc/stable/pandare
# we want to copy auto_pydoc/dev/pandare to auto_pydoc/pandare/ and /auto_pydoc/stable/pandare to /auto_pydoc/pandare/stable
#
# This is a bit complicated, sorry. We want to keep pandare/{CNAME,.git/} and nothing else
# then we copy in the new files (and merge doc-search.html and index.js with dev/pandare/
- name: Push PYPANDA docs to GitHub Pages if docs changed
if: ${{ matrix.ubuntu_version == env.PANDA_CONTAINER_UBUNTU_VERSION }}
run: cd "${GITHUB_WORKSPACE}/auto_pydoc" &&
mv pandare/CNAME dev &&
rm -rf pandare/* &&
mv dev/pandare/* pandare &&
rmdir dev/pandare &&
mv dev/* pandare/ &&
cd pandare &&
git config --global user.email "panda-ci@panda-re.mit.edu" &&
git config --global user.name "PANDA Bot" &&
git add . &&
git commit -m "Documentation update for PANDA commit ${{ github.sha }} branch dev" &&
git push || true
run: |
rm -rf "${GITHUB_WORKSPACE}/auto_pydoc";
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

publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
if: github.repository == 'panda-re/panda' && github.ref == 'refs/heads/dev'
needs:
- build_release_assets
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pandare # Replace <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: pypanda
path: dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true

build_stable:
if: github.repository == 'panda-re/panda' && github.ref == 'refs/heads/stable'
runs-on: panda-arc
steps:
- name: Checkout PANDA at current commit
uses: actions/checkout@v4

- name: 'Login to Docker Registry'
uses: docker/login-action@v3
with:
username: pandare
password: ${{secrets.pandare_dockerhub}}

- name: Build Bionic container
# Push both dev and regular container
uses: docker/build-push-action@v5
with:
push: true
context: ${{ github.workspace }}
tags: |
pandare/panda_stable:${{ github.sha }}
pandare/panda_stable:latest
target: panda

- name: Checkout docs and reset
run: rm -rf "${GITHUB_WORKSPACE}/auto_pydoc";
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

- name: Update PYPANDA docs in container
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/"
# will put docs in workspace/auto_pydoc/dev/pandare and/or workspace/auto_pydoc/stable/pandare
# we want to copy /auto_pydoc/dev/pandare to /auto_doc and /auto_pydoc/stable/pandare to /auto_pydoc/stable
- name: Update PYPANDA docs in container
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/"

# will put docs in workspace/auto_pydoc/{dev, stable}/pandare and/or workspace/auto_pydoc/stable/pandare
# we want to copy auto_pydoc/{dev, stable}/pandare to auto_pydoc/pandare/ and /auto_pydoc/stable/pandare to /auto_pydoc/pandare/stable
#
# This is a bit complicated, sorry. We create a directory stable and combine doc-search.html and index.js in there.
- name: Push PYPANDA docs to GitHub Pages if docs changed
#run: cd "${GITHUB_WORKSPACE}/auto_pydoc/pandare" && mv ./stable ./stable2; mv ./stable2/pandare stable; rm -rf ./stable2;
run: cd "${GITHUB_WORKSPACE}/auto_pydoc" &&
rm -rf pandare/stable &&
mv stable/pandare/* pandare/stable &&
rmdir stable/pandare &&
mv stable/* pandare/stable &&
cd pandare &&
git config --global user.email "panda-ci@panda-re.mit.edu" &&
git config --global user.name "PANDA Bot" &&
git add . &&
git commit -m "Documentation update for PANDA commit ${{ github.sha }} branch stable" &&
git push || true
# This is a bit complicated, sorry. We want to keep pandare/{CNAME,.git/} and nothing else
# then we copy in the new files (and merge doc-search.html and index.js with {dev, stable}/pandare/
- name: Push PYPANDA docs to GitHub Pages if docs changed
run: |
cd "${GITHUB_WORKSPACE}/auto_pydoc"
mv pandare/CNAME ${{ github.ref_name }}
rm -rf pandare/*
mv ${{ github.ref_name }}/pandare/* pandare
rmdir ${{ github.ref_name }}/pandare
mv ${{ github.ref_name }}/* pandare/
cd pandare
git config --global user.email "panda-ci@panda-re.mit.edu"
git config --global user.name "PANDA Bot"
git add .
git commit -m "Documentation update for PANDA commit ${{ github.sha }} branch ${{ github.ref_name }}"
git push || true
3 changes: 2 additions & 1 deletion panda/debian/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
panda.deb
*.deb
*.whl
1 change: 1 addition & 0 deletions panda/python/core/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ data
a
__pycache__
*.egg-info
.eggs/
6 changes: 0 additions & 6 deletions panda/python/core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,3 @@ dependencies = [
"protobuf>=4.25.1",
"colorama"
]

[tool.setuptools_scm]
root = "../../.."
fallback_version = "0.0.0.1"
version_scheme = "guess-next-dev"
local_scheme = "no-local-version"
5 changes: 4 additions & 1 deletion panda/python/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
else:
from setuptools_scm import get_version
version = get_version(root='../../..',
fallback_version="0.0.0.1",
fallback_version="0.0.1",
version_scheme="guess-next-dev",
local_scheme="no-local-version")
# python3 -m setuptools_scm -r .. --strip-dev is implemented here
# https://github.com/pypa/setuptools-scm/blob/62ae6400205533fb4b355170a11295e49b366d23/src/setuptools_scm/_cli.py#L42-L43
version = version.partition(".dev")[0]

with open("README.md", "r") as fh:
long_description = fh.read()
Expand Down
Loading