Skip to content

Commit ea2df39

Browse files
authored
Merge pull request #6 from prompt-security/fix_auto_release_naming
Improve release/tagging/naming workflow
2 parents 1d3344c + be8b77a commit ea2df39

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,18 @@ jobs:
1919
- name: Clean up old distribution
2020
run: bash clean_package.sh
2121

22+
- name: Determine Package Version
23+
id: get_version
24+
run: echo "PKG_VERSION=$(bash get_version.sh)" >> $GITHUB_ENV
25+
2226
- name: Build distribution
2327
run: bash build_package.sh
2428

2529
- name: Create GitHub Release
2630
uses: softprops/action-gh-release@v1
2731
with:
2832
files: dist/*
29-
name: Release ${{ github.ref_name }} of ${{ github.repository }}
30-
body: This is the release of ${{ github.repository }} for version ${{ github.ref_name }}
33+
name: Release ${{ env.PKG_VERSION }} of ${{ github.repository }}
34+
body: This is the release of ${{ github.repository }} for version ${{ env.PKG_VERSION }}
3135
env:
3236
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build_package.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ python -m pip install --upgrade pip setuptools wheel
77
echo "Cleaning up previous builds..."
88
rm -rf build/ dist/ *.egg-info
99

10-
echo "Building the package..."
10+
echo "Determining package version..."
11+
# Use get_version.sh to determine the package version
12+
PKG_VERSION=$(./get_version.sh)
13+
export PKG_VERSION
14+
15+
echo "Building the package with version $PKG_VERSION..."
1116
python setup.py sdist bdist_wheel
1217

1318
echo "Build output:"

get_version.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
# This script determines the current package version based on Git tags and commits.
3+
4+
set -e # Exit immediately in case of error, do not ignore errors
5+
6+
# Determine the package version from Git
7+
current_commit=$(git rev-parse HEAD)
8+
latest_tag_commit=$(git rev-list -n 1 --tags --abbrev=0)
9+
10+
if [ "$current_commit" == "$latest_tag_commit" ]; then
11+
PKG_VERSION=$(git describe --tags --abbrev=0)
12+
else
13+
commit_hash=$(git rev-parse --short HEAD)
14+
date=$(date +%Y%m%d)
15+
PKG_VERSION="0.0.1.dev${date}+${commit_hash}"
16+
fi
17+
18+
echo $PKG_VERSION

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import os
12
from setuptools import setup, find_packages
23

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

67
setup(
78
name="ps_fuzz",
8-
version="1.0.0",
9+
version=os.getenv('PKG_VERSION', '0.0.1'),
910
author="Prompt Security",
1011
author_email="[email protected]",
1112
description="LLM and System Prompt vulnerability scanner tool",

0 commit comments

Comments
 (0)