Skip to content

Refactor rest server implementation #607

Refactor rest server implementation

Refactor rest server implementation #607

Workflow file for this run

name: Release in Pypi/DockerHub
on:
push:
branches:
- main
jobs:
build:
# Any commit message that contains the phrase 'Bump Version' will trigger the release process.
# We have an additional safety mechanism in the upload to PyPI step that requires manual approval.
# This is to prevent accidental releases. All other steps (eg build, upload to GitHub) are reversible
if: ${{ startsWith(github.event.head_commit.message, 'Bump Version') }}
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Python 3.8
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
run: python -m pip install --upgrade build
- name: Build
run: python -m build
# smoke-test that build is valid
- name: Check wheel contents
run: |
python -m pip install check-wheel-contents
check-wheel-contents dist
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
path: ./dist
#---------------------------------------------------
# Build GitHub Artifacts
#---------------------------------------------------
test-build:
needs: ['build']
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'
# Artifacts located in artifact/
- name: Download artifact
uses: actions/download-artifact@v3
- name: Install wheel
run: python -m pip install artifact/*.whl
- name: Set version for tagging
id: set-version
run: |
export PACKAGE_VERSION=$(python -c "import superduperdb as s; print(s.__version__)")
echo "package_version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
outputs:
package_version: ${{ steps.set-version.outputs.package_version }}
#---------------------------------------------------
# Publish GitHub Artifacts
#---------------------------------------------------
create-release:
needs: ['test-build']
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Artifacts located in artifact/
- name: Download artifact
uses: actions/download-artifact@v3
- name: create release
run: >
gh release create ${{ needs.test-build.outputs.package_version }}
--repo ${{ github.repository }} --generate-notes
artifact/*
env:
GH_TOKEN: ${{ github.token }}
#---------------------------------------------------
# Publish SuperDuperDB in Pypi
#---------------------------------------------------
publish-pypi:
needs: ['create-release']
# Environment waits for approval before attempting to upload to PyPI.
# This allows reviewing the files in the release on GitHub.
environment: publish-pypi
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
# Try uploading to Test PyPI first, in case something fails.
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: artifact/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: artifact/
#---------------------------------------------------
# Publish SuperDuperDB in DockerHub
#---------------------------------------------------
publish-docker:
needs: ['publish-pypi']
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push Base Docker image
run: |
make build_superduperdb
make push_superduperdb