Skip to content

Commit

Permalink
Merge pull request #6 from prompt-security/fix_auto_release_naming
Browse files Browse the repository at this point in the history
Improve release/tagging/naming workflow
  • Loading branch information
vitaly-ps authored Apr 15, 2024
2 parents 1d3344c + be8b77a commit ea2df39
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ jobs:
- name: Clean up old distribution
run: bash clean_package.sh

- name: Determine Package Version
id: get_version
run: echo "PKG_VERSION=$(bash get_version.sh)" >> $GITHUB_ENV

- name: Build distribution
run: bash build_package.sh

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: dist/*
name: Release ${{ github.ref_name }} of ${{ github.repository }}
body: This is the release of ${{ github.repository }} for version ${{ github.ref_name }}
name: Release ${{ env.PKG_VERSION }} of ${{ github.repository }}
body: This is the release of ${{ github.repository }} for version ${{ env.PKG_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 6 additions & 1 deletion build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ python -m pip install --upgrade pip setuptools wheel
echo "Cleaning up previous builds..."
rm -rf build/ dist/ *.egg-info

echo "Building the package..."
echo "Determining package version..."
# Use get_version.sh to determine the package version
PKG_VERSION=$(./get_version.sh)
export PKG_VERSION

echo "Building the package with version $PKG_VERSION..."
python setup.py sdist bdist_wheel

echo "Build output:"
Expand Down
18 changes: 18 additions & 0 deletions get_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# This script determines the current package version based on Git tags and commits.

set -e # Exit immediately in case of error, do not ignore errors

# Determine the package version from Git
current_commit=$(git rev-parse HEAD)
latest_tag_commit=$(git rev-list -n 1 --tags --abbrev=0)

if [ "$current_commit" == "$latest_tag_commit" ]; then
PKG_VERSION=$(git describe --tags --abbrev=0)
else
commit_hash=$(git rev-parse --short HEAD)
date=$(date +%Y%m%d)
PKG_VERSION="0.0.1.dev${date}+${commit_hash}"
fi

echo $PKG_VERSION
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import os
from setuptools import setup, find_packages

with open('README.md', 'r', encoding='utf-8') as fh:
long_description = fh.read()

setup(
name="ps_fuzz",
version="1.0.0",
version=os.getenv('PKG_VERSION', '0.0.1'),
author="Prompt Security",
author_email="support@prompt.security",
description="LLM and System Prompt vulnerability scanner tool",
Expand Down

0 comments on commit ea2df39

Please sign in to comment.