Skip to content

Merge remote-tracking branch 'origin/master' #123

Merge remote-tracking branch 'origin/master'

Merge remote-tracking branch 'origin/master' #123

name: CI
on:
push:
branches:
- master
jobs:
versioning:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Increment version
uses: saleweaver/version_increment_action@v1
with:
file_path: "sp_api/__version__.py"
version_key: "__version__"
- name: Install Dependencies
if: env.new_version != ''
run: |
python -m pip install --upgrade pip
pip install openai
- name: Get Latest Bump Version Commits
if: env.new_version != ''
id: get_commits
run: |
COMMITS=$(git log --grep='^Bump version' --pretty=format:"%H" -n 2)
echo $COMMITS
echo "commits<<EOF" >> $GITHUB_OUTPUT
echo "$COMMITS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Generate Diff
if: env.new_version != ''
id: generate_diff
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
COMMITS="${{ steps.get_commits.outputs.commits }}"
COMMITS_ARRAY=($COMMITS)
if [ ${#COMMITS_ARRAY[@]} -lt 2 ]; then
echo "No previous Bump version commit found. Skipping changelog."
echo "diff=" >> $GITHUB_OUTPUT
exit 0
fi
OLD_COMMIT=${COMMITS_ARRAY[1]}
NEW_COMMIT=${COMMITS_ARRAY[0]}
git diff $OLD_COMMIT $NEW_COMMIT > changelog_diff.patch
python generate_changelog.py changelog_diff.patch
- name: Update CHANGELOG.md
if: steps.generate_diff.outputs.diff != '' && env.new_version != ''
run: |
echo "## v${{ env.new_version }} - $(date +'%Y-%m-%d')" >> CHANGELOG.md
cat changelog_entry.md >> CHANGELOG.md
echo "" >> CHANGELOG.md
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add CHANGELOG.md
git commit -m "chore: update CHANGELOG.md for v${{ env.new_version }}"
git push
# - name: Create a new GitHub release
# if: env.new_version != ''
# uses: actions/create-release@v1
# with:
# tag_name: "v${{ env.new_version }}"
# release_name: "v${{ env.new_version }}"
# draft: false
# prerelease: false
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Trigger release workflow
# if: env.new_version != ''
# run: |
# curl -X POST \
# -H "Accept: application/vnd.github.v3+json" \
# -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
# https://api.github.com/repos/${{ github.repository }}/dispatches \
# -d '{"event_type": "release_created", "client_payload": { "version": "${{ env.new_version }}" }}'