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" 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 }}