Skip to content

Development

Development #41

name: build-latest-container
on:
pull_request:
branches: [master]
paths:
- '**.py'
- .github/workflows/build_latest_container.yaml
- Dockerfile.prod
release:
types: [published]
env:
REGISTRY: ghcr.io
PYTHON_VERSION: '3.10'
permissions:
contents: read
packages: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
set-safe-directory: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Check git version and our path
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Install yapf
run: |
python -m pip install --upgrade pip
pip install yapf
- name: Run yapf
run: |
yapf --recursive --verbose --diff .
build:
runs-on: ubuntu-latest
needs: lint
container:
image: ghcr.io/${{ github.repository }}:base
credentials:
username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
set-safe-directory: true
- name: Force directory safe
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip wheel setuptools setuptools-scm
python3 -m pip install build
- name: Build package
run: python3 -m build
- name: Install snow
run: pip install dist/*.tar.gz
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: snow-artifacts
path: dist/*
- name: Run commands to test that everything is finished
run: |
pip3 freeze | grep "snow"
python3 -c "import snow"
build-latest-container:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.prod
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max