From 1a7e8eebd488e4b28690592ae118fb17174a9ddf Mon Sep 17 00:00:00 2001 From: pgoslatara Date: Sat, 29 Jun 2024 22:43:36 +0200 Subject: [PATCH] Moving to release pipeline --- .github/workflows/cd_pipeline.yml | 55 --------------- .github/workflows/release_pipeline.yml | 98 ++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 55 deletions(-) delete mode 100644 .github/workflows/cd_pipeline.yml create mode 100644 .github/workflows/release_pipeline.yml diff --git a/.github/workflows/cd_pipeline.yml b/.github/workflows/cd_pipeline.yml deleted file mode 100644 index d7bde3ed..00000000 --- a/.github/workflows/cd_pipeline.yml +++ /dev/null @@ -1,55 +0,0 @@ ---- -name: CD pipeline - -on: - push: - branches: - - main - -jobs: - cd_pipeline: - name: Build Docker image - runs-on: ubuntu-latest - permissions: - packages: write - steps: - - uses: actions/checkout@v4 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - dbt-bouncer - tags: | - type=ref,event=branch - type=raw,value=${{ github.sha }} - type=raw,value=test - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: https://ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Determine python version - id: python-version - run: | - export PYTHON_VERSION=$(cat .python-version) - echo "PYTHON_VERSION: $PYTHON_VERSION" - echo "PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_OUTPUT - - - name: Build image - uses: docker/build-push-action@v5 - with: - build-args: PYTHON_VERSION=${{ steps.python-version.outputs.PYTHON_VERSION }} - cache-from: type=gha - cache-to: type=gha,mode=max - context: . - load: false - push: false - tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/release_pipeline.yml b/.github/workflows/release_pipeline.yml new file mode 100644 index 00000000..cd064c42 --- /dev/null +++ b/.github/workflows/release_pipeline.yml @@ -0,0 +1,98 @@ +--- +name: Release pipeline + +on: + workflow_dispatch: + inputs: + prerelease: + default: false + description: The release will be labeled as non-production ready. + required: false + type: boolean + version_bump_type: + description: The version bump type to perform. + required: true + type: choice + options: + - major + - minor + - patch + - prerelease + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + packages: write + steps: + - name: Validated users only + if: github.actor != 'pgoslatara' + run: exit 1 + + - uses: actions/checkout@v4 + + - name: Setup Python + id: setup-python + uses: actions/setup-python@v5 + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + installer-parallel: true + version: 1.7.1 + virtualenvs-create: true + virtualenvs-in-project: true + + - name: Install version bump Poetry plugin + run: poetry self add poetry-bumpversion + + - name: Bump version + run: poetry version ${{ inputs.version_bump_type }} + + - name: Save version to env var + id: version + run: echo "version=$(poetry version --short)" >> $GITHUB_OUTPUT + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=${{ github.sha }} + type=raw,value=${{ steps.version.outputs.version }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + password: ${{ secrets.GITHUB_TOKEN }} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + + - name: Determine python version + id: python-version + run: | + export PYTHON_VERSION=$(cat .python-version) + echo "PYTHON_VERSION: $PYTHON_VERSION" + echo "PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_OUTPUT + + - name: Build and push image + id: push + uses: docker/build-push-action@v5 + with: + build-args: PYTHON_VERSION=${{ steps.python-version.outputs.PYTHON_VERSION }} + cache-from: type=gha + cache-to: type=gha,mode=max + context: . + load: false + push: true + tags: ${{ steps.meta.outputs.tags }}