Skip to content

Commit

Permalink
Modified workflow actions to generate latest tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Prateek-Thakare committed Jun 5, 2024
1 parent 530b8a6 commit 00fe688
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 24 deletions.
23 changes: 23 additions & 0 deletions .github/actions/setup-python-and-git/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: checkout-and-setup-python
description: 'Checkout the repository and setup Python'
inputs:
python-version:
description: 'Python version to use'
required: false
default: '3.11'
runs:
using: 'composite'
steps:
- uses: actions/setup-python@v4
name: Setup Python
with:
python-version: ${{ inputs.python-version }}
cache: 'pip' # caching pip dependencies

- name: Git check
run: |
git config --global user.email "[email protected]"
git config --global user.name "mantis"
git --version
git config --list
shell: bash
54 changes: 33 additions & 21 deletions .github/workflows/mantis-cli-release.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Mantis CLI Release
name: Mantis CLI Latest Release
on:
push:
branches:
- main
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: phonepe/mantis

jobs:
build-and-push-image:
if: github.event_name == 'workflow_dispatch'
Expand All @@ -20,26 +20,36 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4

- name: Setup Python and Git
uses: ./.github/actions/setup-python-and-git
with:
python-version: '3.9'

- name: Install Poetry and bump2version
run: pip install poetry==1.4.2 bump2version==1.0.1
- name: Install Poetry
run: pip install poetry==1.4.2

- name: Determine Current Version
run: |
latest_version=$(poetry version --short)
echo "LATEST_VERSION=$latest_version" >> $GITHUB_ENV
- name: Check if Git Tag Exists
id: git-tag
run: |
if git rev-parse "$latest_version" >/dev/null 2>&1; then
echo "Tag $latest_version already exists."
exit 0
else
echo "Tag $latest_version does not exist."
echo "CREATE_TAG=true" >> $GITHUB_ENV
fi
- name: Bump version
id: bump_version
run: poetry run bump2version patch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Push version bump commit and tag
- name: Create Git Tag
if: env.CREATE_TAG == 'true'
run: |
git push origin main --tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
git tag -a "$LATEST_VERSION" -m "Release $LATEST_VERSION"
git push origin "$LATEST_VERSION"
- name: Log in to the Container registry
uses: docker/login-action@v2
Expand All @@ -50,14 +60,16 @@ jobs:

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.bump_version.outputs.new_version }}
labels: ${{ steps.meta.outputs.labels }}
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.LATEST_VERSION }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}
14 changes: 11 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
[tool.poetry]
name = "mantis"
version = "0.1.0"
version = "1.0.0"
description = "Mantis is a security framework that automates the workflow of discovery, reconnaissance, and vulnerability scanning."
authors = ["Prateek Thakare <[email protected]>",
"Praveen Kanniah <[email protected]>"]
"Bharath Kumar <[email protected]>",
"Saddam Hussain <[email protected]>",
"Hitesh Kumar <[email protected]>",
"Praveen Kanniah <[email protected]>"
]
maintainers = ["Prateek Thakare <[email protected]>",
"Praveen Kanniah <[email protected]>"]
"Bharath Kumar <[email protected]>",
"Saddam Hussain <[email protected]>",
"Hitesh Kumar <[email protected]>",
"Praveen Kanniah <[email protected]>"
]
license = "apache2"
repository = "https://github.com/PhonePe/mantis"
keywords = ["asset discovery", "recon", "recon automation", "osint", "threat intelligence", "recon framework"]
Expand Down

0 comments on commit 00fe688

Please sign in to comment.