Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve release/tagging/naming workflow #6

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading