Skip to content

Issue 386 opportunity search #411

Issue 386 opportunity search

Issue 386 opportunity search #411

name: "CI - Bump Version & Create Tag"
on:
push:
branches:
- main
pull_request:
permissions:
contents: write
jobs:
version:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.18.3
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Poetry
uses: Gr1N/setup-poetry@v8
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build core library
run: pnpm --filter @common-grants/core run build
- name: Build cli library
run: pnpm --filter @common-grants/cli run build
- name: Install python-sdk dependencies
working-directory: ./lib/python-sdk
run: poetry install
- name: Detect changesets
id: check_changesets
run: |
# Find changeset files
CHANGESET_FILES=$(find .changeset -type f -name "*.md" ! -name "README.md")
if [ -z "$CHANGESET_FILES" ]; then
echo "No changeset files found"
echo "found=false" >> $GITHUB_OUTPUT
exit 0
fi
# Inspect changeset files
echo "Found changeset files: $CHANGESET_FILES"
echo "found=true" >> $GITHUB_OUTPUT
PY_CHANGELOG=$(grep '"common-grants-sdk":' $CHANGESET_FILES || true)
if [ -z "$PY_CHANGELOG" ]; then
echo "found_py=false" >> $GITHUB_OUTPUT
exit 0
else
echo "found_py=true" >> $GITHUB_OUTPUT
echo "py_changelog=$PY_CHANGELOG" >> $GITHUB_OUTPUT
fi
- name: Bump version for Python package
working-directory: ./lib/python-sdk
if: steps.check_changesets.outputs.found_py == 'true'
run: |
CHANGELOG="${{ steps.check_changesets.outputs.py_changelog }}"
if [ -z "$CHANGELOG" ]; then
echo "No bump needed for Python package"
exit 0
elif echo "$CHANGELOG" | grep -q 'major'; then
echo "Major bump needed for Python package"
poetry version major
elif echo "$CHANGELOG" | grep -q 'minor'; then
echo "Minor bump needed for Python package"
poetry version minor
elif echo "$CHANGELOG" | grep -q 'patch'; then
echo "Patch bump needed for Python package"
poetry version patch
fi
- name: Bump version for Node package
if: steps.check_changesets.outputs.found == 'true'
run: |
pnpm changeset version
git status
- name: Commit bumped version
if: steps.check_changesets.outputs.found == 'true' && github.event_name != 'pull_request'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit --no-verify -m "chore: bump version [skip ci]" || echo "No changes to commit"
git push
- name: Create tag for Python package
if: steps.check_changesets.outputs.found_py == 'true'
working-directory: ./lib/python-sdk
run: |
PKG_NAME=$(poetry run tomlq -r .tool.poetry.name pyproject.toml)
PY_VERSION=$(poetry run tomlq -r .tool.poetry.version pyproject.toml)
git tag ${PKG_NAME}@${PY_VERSION}
echo "Added tag: ${PKG_NAME}@${PY_VERSION}"
- name: Create tag for Node package
if: steps.check_changesets.outputs.found == 'true'
run: pnpm changeset tag
- name: Push tags
if: steps.check_changesets.outputs.found == 'true' && github.event_name != 'pull_request'
run: git push --tags