Release package #93
This file contains hidden or 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: Release package | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag to release (e.g. v0.23.0)" | |
| required: true | |
| type: string | |
| push: | |
| tags: | |
| - v[0-9].[0-9]+.[0-9]+ | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| validate-packages-yml: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Elementary | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ inputs.tag || github.ref }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.10" | |
| - name: Install PyYAML | |
| run: pip install pyyaml | |
| - name: Validate dbt-data-reliability is not a git hash reference | |
| run: | | |
| python - <<'EOF' | |
| import yaml | |
| import sys | |
| packages_file = "./elementary/monitor/dbt_project/packages.yml" | |
| with open(packages_file) as f: | |
| data = yaml.safe_load(f) | |
| packages = data.get("packages", []) | |
| has_git_ref = any( | |
| "git" in pkg and "dbt-data-reliability" in pkg["git"] | |
| for pkg in packages | |
| ) | |
| if has_git_ref: | |
| print("::error::packages.yml contains a git hash reference for dbt-data-reliability. " | |
| "Releases must use a proper package version (e.g. 'package: elementary-data/elementary' " | |
| "with a 'version:' field). Please update packages.yml before releasing.") | |
| sys.exit(1) | |
| has_package_ref = any( | |
| pkg.get("package") == "elementary-data/elementary" | |
| for pkg in packages | |
| ) | |
| if not has_package_ref: | |
| print("::error::packages.yml does not contain a proper package reference for " | |
| "elementary-data/elementary. Please update packages.yml before releasing.") | |
| sys.exit(1) | |
| print("packages.yml validation passed - using proper package version reference.") | |
| EOF | |
| publish-to-pypi: | |
| needs: validate-packages-yml | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Elementary | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ inputs.tag || github.ref }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.10" | |
| - name: Install 'build' package | |
| run: pip install build | |
| - name: Build package | |
| run: python -m build --sdist --wheel --outdir dist . | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: build | |
| path: dist | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: ${{ secrets.PYPI_USER }} | |
| password: ${{ secrets.PYPI_PASS }} | |
| build-and-push-docker-image: | |
| needs: validate-packages-yml | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout Elementary | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ inputs.tag || github.ref }} | |
| - name: Set up QEMU for multi-platform support | |
| uses: docker/setup-qemu-action@v4 | |
| - name: Set up Docker Buildx for multi-platform support | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to the container registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=semver,pattern={{version}},value=${{ inputs.tag || '' }} | |
| type=ref,event=tag | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| merge-to-docs: | |
| needs: validate-packages-yml | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ inputs.tag || github.ref }} | |
| - name: PR master to docs | |
| uses: repo-sync/pull-request@v2 | |
| with: | |
| source_branch: master | |
| destination_branch: docs |