Drop support for dbt 0.x (#561) #345
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: CD | |
env: | |
PYTHON_VERSION: 3.8 | |
POETRY_VERSION: 1.2.2 | |
NODE_VERSION: 16 | |
DOCKER_IMAGE: metaphordata/connectors | |
# Run this build workflow after a new PR is merged | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
version: | |
name: Get version | |
runs-on: ubuntu-latest | |
outputs: | |
full: ${{ steps.get-version.outputs.full }} | |
major: ${{ steps.get-version.outputs.major }} | |
minor: ${{ steps.get-version.outputs.minor }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- run: npm install toml | |
- id: get-version | |
name: Get version | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
const fs = require('fs'); | |
const toml = require('toml'); | |
const pyproject = toml.parse(fs.readFileSync('pyproject.toml')); | |
const version = pyproject.tool.poetry.version; | |
core.setOutput('full', version); | |
core.setOutput('major', version.split('.').slice(0, 1).join('.')); | |
core.setOutput('minor', version.split('.').slice(0, 2).join('.')); | |
publish-coverage: | |
name: Publish coverage stats | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Setup Poetry | |
uses: abatilo/[email protected] | |
with: | |
poetry-version: ${{ env.POETRY_VERSION }} | |
- name: Test | |
run: | | |
poetry install -E all | |
poetry run coverage run --source=metaphor -m pytest | |
poetry run coverage xml | |
- name: Codecov | |
uses: codecov/codecov-action@v3 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
pypi: | |
name: Publish to PyPI | |
runs-on: ubuntu-latest | |
needs: version | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Setup Poetry | |
uses: abatilo/[email protected] | |
with: | |
poetry-version: ${{ env.POETRY_VERSION }} | |
- name: Publish to PyPI | |
run: > | |
poetry publish --build --skip-existing | |
-u ${{ secrets.PYPI_USERNAME }} | |
-p ${{ secrets.PYPI_PASSWORD }} | |
- name: Create tag | |
uses: actions/github-script@v5 | |
with: | |
github-token: ${{ github.token }} | |
script: | | |
const version = '${{ needs.version.outputs.full }}'; | |
core.notice(`Tagging ${{ github.sha }} as ${version}`); | |
try { | |
await github.rest.git.deleteRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: `tags/${ version }` | |
}); | |
} catch (err) {} | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: `refs/tags/${ version }`, | |
sha: "${{ github.sha }}" | |
}) | |
docker: | |
name: Publish to Docker | |
runs-on: ubuntu-latest | |
needs: version | |
steps: | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Check existing version | |
id: check | |
continue-on-error: true | |
run: docker manifest inspect ${{ env.DOCKER_IMAGE }}:${{ needs.version.outputs.full }} > /dev/null | |
- name: Build Docker image | |
if: steps.check.outcome == 'failure' | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: | | |
${{ env.DOCKER_IMAGE }}:latest | |
${{ env.DOCKER_IMAGE }}:${{ needs.version.outputs.full }} | |
${{ env.DOCKER_IMAGE }}:${{ needs.version.outputs.major }} | |
${{ env.DOCKER_IMAGE }}:${{ needs.version.outputs.minor }} |