Skip to content

Commit

Permalink
ci: autorelease (#72)
Browse files Browse the repository at this point in the history
* feat: make deepsearch-toolkit optional

Signed-off-by: Michele Dolfi <[email protected]>

* add tqdm

Signed-off-by: Michele Dolfi <[email protected]>

* remove textcolor dependency

Signed-off-by: Michele Dolfi <[email protected]>

* ci: add automated releases

Signed-off-by: Michele Dolfi <[email protected]>

* add andromeda_nlp to exclude list

Signed-off-by: Michele Dolfi <[email protected]>

* more andromeda_ ignores

Signed-off-by: Michele Dolfi <[email protected]>

* run checks after install

Signed-off-by: Michele Dolfi <[email protected]>

* fix pylint

Signed-off-by: Michele Dolfi <[email protected]>

---------

Signed-off-by: Michele Dolfi <[email protected]>
  • Loading branch information
dolfim-ibm authored Sep 10, 2024
1 parent f9e0a0e commit 57e2334
Show file tree
Hide file tree
Showing 12 changed files with 1,451 additions and 756 deletions.
19 changes: 19 additions & 0 deletions .github/actions/setup-poetry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Set up Poetry and install'
description: 'Set up a specific version of Poetry and install dependencies using caching.'
inputs:
python-version:
description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax."
default: '3.11'
runs:
using: 'composite'
steps:
- name: Install poetry
run: pipx install poetry==1.8.3
shell: bash
- uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
cache: 'poetry'
- name: Install only dependencies and not the package itself
run: poetry install --all-extras --no-root
shell: bash
39 changes: 39 additions & 0 deletions .github/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

set -e # trigger failure on error - do not remove!
set -x # display command on output

if [ -z "${TARGET_VERSION}" ]; then
>&2 echo "No TARGET_VERSION specified"
exit 1
fi
CHGLOG_FILE="${CHGLOG_FILE:-CHANGELOG.md}"

# update package version
poetry version "${TARGET_VERSION}"

# collect release notes
REL_NOTES=$(mktemp)
poetry run semantic-release changelog --unreleased >> "${REL_NOTES}"

# update changelog
TMP_CHGLOG=$(mktemp)
TARGET_TAG_NAME="v${TARGET_VERSION}"
RELEASE_URL="$(gh repo view --json url -q ".url")/releases/tag/${TARGET_TAG_NAME}"
printf "## [${TARGET_TAG_NAME}](${RELEASE_URL}) - $(date -Idate)\n\n" >> "${TMP_CHGLOG}"
cat "${REL_NOTES}" >> "${TMP_CHGLOG}"
if [ -f "${CHGLOG_FILE}" ]; then
printf "\n" | cat - "${CHGLOG_FILE}" >> "${TMP_CHGLOG}"
fi
mv "${TMP_CHGLOG}" "${CHGLOG_FILE}"

# push changes
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add pyproject.toml "${CHGLOG_FILE}"
COMMIT_MSG="chore: bump version to ${TARGET_VERSION} [skip ci]"
git commit -m "${COMMIT_MSG}"
git push origin main

# create GitHub release (incl. Git tag)
gh release create "${TARGET_TAG_NAME}" -F "${REL_NOTES}"
50 changes: 50 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "Run CD"

on:
push:
branches:
- main

env:
# disable keyring (https://github.com/actions/runner-images/issues/6185):
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring

jobs:
code-checks:
uses: ./.github/workflows/checks.yml
pre-release-check:
runs-on: ubuntu-latest
outputs:
TARGET_TAG_V: ${{ steps.version_check.outputs.TRGT_VERSION }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # for fetching tags, required for semantic-release
- uses: ./.github/actions/setup-poetry
- name: Check version of potential release
id: version_check
run: |
TRGT_VERSION=$(poetry run semantic-release print-version)
echo "TRGT_VERSION=${TRGT_VERSION}" >> $GITHUB_OUTPUT
echo "${TRGT_VERSION}"
- name: Check notes of potential release
run: poetry run semantic-release changelog --unreleased
release:
needs: [code-checks, pre-release-check]
if: needs.pre-release-check.outputs.TARGET_TAG_V != ''
environment: auto-release
runs-on: ubuntu-latest
concurrency: release
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
fetch-depth: 0 # for fetching tags, required for semantic-release
- uses: ./.github/actions/setup-poetry
- name: Run release script
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
TARGET_VERSION: ${{ needs.pre-release-check.outputs.TARGET_TAG_V }}
CHGLOG_FILE: CHANGELOG.md
run: ./.github/scripts/release.sh
shell: bash
31 changes: 31 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
workflow_call:

env:
CMAKE_BUILD_TYPE: Debug

jobs:
run-checks:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
# - name: Install dependencies [linux]
# run: sudo apt-get install -y libldap-common
# shell: bash
- uses: ./.github/actions/setup-poetry
with:
python-version: ${{ matrix.python-version }}
- name: Install with poetry
run: poetry install --all-extras
- name: Run styling check
run: poetry run pre-commit run --all-files
- name: Testing
run: |
poetry run pytest ./tests/test_structs.py -v
poetry run pytest ./tests/test_nlp.py -v
poetry run pytest ./tests/test_glm.py -v
- name: Build with poetry
run: poetry build
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Run CI"

on:
schedule: # will run only on the default branch (main)
# Nightly build at 3:42 A.M.
- cron: "42 3 */1 * *"
pull_request:
types: [opened, reopened]
push:
branches:
- "**"
- "!main"
- "!gh-pages"

env:
# disable keyring (https://github.com/actions/runner-images/issues/6185):
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring

jobs:
code-checks:
uses: ./.github/workflows/checks.yml
build-wheels:
uses: ./.github/workflows/wheels.yml

41 changes: 0 additions & 41 deletions .github/workflows/cmake.yml

This file was deleted.

13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Build and publish package"

on:
release:
types: [published]

permissions:
contents: read

jobs:
build-and-publish:
uses: ./.github/workflows/wheels.yml
secrets: inherit
44 changes: 0 additions & 44 deletions .github/workflows/tests.yml

This file was deleted.

Loading

0 comments on commit 57e2334

Please sign in to comment.