Skip to content

Merge pull request #25 from PhonePe/mr_workflow #23

Merge pull request #25 from PhonePe/mr_workflow

Merge pull request #25 from PhonePe/mr_workflow #23

name: Mantis CLI Release
on:
push:
branches:
- main
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: phonepe/mantis
jobs:
build-and-push-image:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Poetry and bump2version
run: pip install poetry==1.4.2 bump2version==1.0.1
- name: Bump version
id: bump_version
run: poetry run bump2version patch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push version bump commit and tag
run: |
git push origin main --tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.bump_version.outputs.new_version }}
labels: ${{ steps.meta.outputs.labels }}