From 6a4cdeda08fafd2a6297b68756a847a39c392297 Mon Sep 17 00:00:00 2001 From: Vaclav Lunak Date: Sun, 1 Oct 2023 11:00:20 +0200 Subject: [PATCH 1/2] add container packaging pipeline --- .github/workflows/pull_requests.yml | 42 ++++++++++++--------------- .github/workflows/release.yml | 45 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 1abd97d..5cea9d1 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -1,36 +1,30 @@ name: CI actions on: [pull_request] jobs: - install: - name: Install + ci: + name: Run CI validation runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - name: Setup + + - name: Install Poetry + run: pipx install poetry==1.6.1 + shell: bash + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + cache: "poetry" + - name: Install dependencies run: poetry install - lint: - needs: [install] - name: Lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - name: Setup + + - name: Lint with flake8 + run: poetry run flake8 . --count --statistics --show-source + - name: Check formatting with Black run: poetry run black --check --diff . + - name: Check imports with isort run: poetry run isort --check --diff . - - name: Lint with flake8 - run: poetry run flake8 . --count --statistics --show-source - test: - needs: [install] - name: Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup - uses: ./.github/actions/setup - - name: Dummy test script - run: echo "OK" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3780a05 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: Create and publish a Docker image + +on: + release: + types: [published] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: log in to the container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 1e8f504f07a2f1f48b446d20c165562242a0a6a1 Mon Sep 17 00:00:00 2001 From: Vaclav Lunak Date: Sun, 1 Oct 2023 11:01:20 +0200 Subject: [PATCH 2/2] remove setup action --- .github/actions/setup/action.yml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .github/actions/setup/action.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml deleted file mode 100644 index 6cefcc6..0000000 --- a/.github/actions/setup/action.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: "Environment Setup" -description: "Common steps needed to create a usable CI environment" -runs: - using: "composite" - steps: - - name: Install Poetry - run: pipx install poetry==1.6.1 - shell: bash - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - cache: "poetry"