From 00fe68836b0d07fe0b527b6bc48e0a4f4735e5d1 Mon Sep 17 00:00:00 2001 From: Prateek Thakare Date: Wed, 5 Jun 2024 12:09:20 +0530 Subject: [PATCH] Modified workflow actions to generate latest tag --- .../actions/setup-python-and-git/action.yaml | 23 ++++++++ .github/workflows/mantis-cli-release.yml | 54 +++++++++++-------- pyproject.toml | 14 +++-- 3 files changed, 67 insertions(+), 24 deletions(-) create mode 100644 .github/actions/setup-python-and-git/action.yaml diff --git a/.github/actions/setup-python-and-git/action.yaml b/.github/actions/setup-python-and-git/action.yaml new file mode 100644 index 00000000..d413bf36 --- /dev/null +++ b/.github/actions/setup-python-and-git/action.yaml @@ -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 "mantis@github.actions" + git config --global user.name "mantis" + git --version + git config --list + shell: bash \ No newline at end of file diff --git a/.github/workflows/mantis-cli-release.yml b/.github/workflows/mantis-cli-release.yml index 66934d88..67df7127 100644 --- a/.github/workflows/mantis-cli-release.yml +++ b/.github/workflows/mantis-cli-release.yml @@ -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' @@ -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 @@ -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 }} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index e11b2407..7aef8678 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 ", - "Praveen Kanniah "] + "Bharath Kumar ", + "Saddam Hussain ", + "Hitesh Kumar <0hitesh.thakur@gmail.com>", + "Praveen Kanniah " + ] maintainers = ["Prateek Thakare ", - "Praveen Kanniah "] + "Bharath Kumar ", + "Saddam Hussain ", + "Hitesh Kumar <0hitesh.thakur@gmail.com>", + "Praveen Kanniah " + ] license = "apache2" repository = "https://github.com/PhonePe/mantis" keywords = ["asset discovery", "recon", "recon automation", "osint", "threat intelligence", "recon framework"]