Skip to content

chore(ci): build and publish docker image #75

chore(ci): build and publish docker image

chore(ci): build and publish docker image #75

Workflow file for this run

name: 🚀 CI/CD
on:
push:
jobs:
test_and_build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Load Cached Poetry
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-dependencies-v2
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-in-project: true
- name: Load Cached Python Dependencies
uses: actions/cache@v2
with:
path: .venv
key: python-dependencies-${{ hashFiles('**/poetry.lock') }}
- name: Install Python Dependencies
run: poetry install
- name: Install APT Dependencies
uses: upciti/wakemeops-action@v1
with:
packages: |
debhelper
fakeroot
- name: Run ruff format
run: poetry run ruff format
- name: Run ruff check
run: poetry run ruff check
- name: Run pytest
run: poetry run pytest --cov=src --cov-report=term-missing tests
- name: Generate coverage report
shell: bash
run: poetry run coverage xml
- uses: codecov/codecov-action@v2
with:
files: ./coverage.xml
- name: Build single binary application
run: |
poetry install --extras pyinstaller
poetry run poetry-dynamic-versioning
poetry run pyinstaller --onefile src/wheel2deb/__main__.py --name wheel2deb -s
dist/wheel2deb version
dist/wheel2deb
mv dist/wheel2deb wheel2deb_linux_amd64
- name: Upload build artifact
uses: actions/upload-artifact@v2
with:
name: wheel2deb_linux_amd64
path: wheel2deb_linux_amd64
retention-days: 2
publish_release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [test_and_build]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install clog-cli
uses: upciti/wakemeops-action@v1
with:
packages: clog-cli
- name: Build Release Changelog
run: |
clog --setversion $(git tag --sort=creatordate | tail -n1) \
--from $(git tag --sort=creatordate | tail -n2 | head -n1) \
-o changelog.md \
-r https://github.com/upciti/wheel2deb
- name: Download build artifact
uses: actions/download-artifact@v2
with:
name: wheel2deb_linux_amd64
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body_path: changelog.md
files: wheel2deb_linux_amd64
publish_pypi:
runs-on: ubuntu-20.04
needs: [test_and_build]
if: startsWith(github.ref, 'refs/tags')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: "3.11"
- name: Load Cached Poetry
uses: actions/cache@v2
with:
path: ~/.local
key: poetry-dependencies-v2
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Get Release Version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build Distribution
run: |
poetry version "$RELEASE_VERSION"
poetry build
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
publish_image:
runs-on: ubuntu-latest
needs: [test_and_build]
#if: github.event.repository.fork == false && startsWith(github.ref, 'refs/tags')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: wheel2deb_linux_amd64
- name: Set execute permission
run: chmod +x wheel2deb_linux_amd64
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/upciti/wheel2deb
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
build-args: |
WHEEL2DEB_PATH=wheel2deb_linux_amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Check Docker image
run: docker run --rm -i ghcr.io/${{ github.event.repository.full_name }}:latest --help
- name: Publish Docker image
run: |
docker push --all-tags ghcr.io/${{ github.event.repository.full_name }}