Skip to content

Commit 57e2334

Browse files
authored
ci: autorelease (#72)
* 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]>
1 parent f9e0a0e commit 57e2334

File tree

12 files changed

+1451
-756
lines changed

12 files changed

+1451
-756
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Set up Poetry and install'
2+
description: 'Set up a specific version of Poetry and install dependencies using caching.'
3+
inputs:
4+
python-version:
5+
description: "Version range or exact version of Python or PyPy to use, using SemVer's version range syntax."
6+
default: '3.11'
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- name: Install poetry
11+
run: pipx install poetry==1.8.3
12+
shell: bash
13+
- uses: actions/setup-python@v4
14+
with:
15+
python-version: ${{ inputs.python-version }}
16+
cache: 'poetry'
17+
- name: Install only dependencies and not the package itself
18+
run: poetry install --all-extras --no-root
19+
shell: bash

.github/scripts/release.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
set -e # trigger failure on error - do not remove!
4+
set -x # display command on output
5+
6+
if [ -z "${TARGET_VERSION}" ]; then
7+
>&2 echo "No TARGET_VERSION specified"
8+
exit 1
9+
fi
10+
CHGLOG_FILE="${CHGLOG_FILE:-CHANGELOG.md}"
11+
12+
# update package version
13+
poetry version "${TARGET_VERSION}"
14+
15+
# collect release notes
16+
REL_NOTES=$(mktemp)
17+
poetry run semantic-release changelog --unreleased >> "${REL_NOTES}"
18+
19+
# update changelog
20+
TMP_CHGLOG=$(mktemp)
21+
TARGET_TAG_NAME="v${TARGET_VERSION}"
22+
RELEASE_URL="$(gh repo view --json url -q ".url")/releases/tag/${TARGET_TAG_NAME}"
23+
printf "## [${TARGET_TAG_NAME}](${RELEASE_URL}) - $(date -Idate)\n\n" >> "${TMP_CHGLOG}"
24+
cat "${REL_NOTES}" >> "${TMP_CHGLOG}"
25+
if [ -f "${CHGLOG_FILE}" ]; then
26+
printf "\n" | cat - "${CHGLOG_FILE}" >> "${TMP_CHGLOG}"
27+
fi
28+
mv "${TMP_CHGLOG}" "${CHGLOG_FILE}"
29+
30+
# push changes
31+
git config --global user.name 'github-actions[bot]'
32+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
33+
git add pyproject.toml "${CHGLOG_FILE}"
34+
COMMIT_MSG="chore: bump version to ${TARGET_VERSION} [skip ci]"
35+
git commit -m "${COMMIT_MSG}"
36+
git push origin main
37+
38+
# create GitHub release (incl. Git tag)
39+
gh release create "${TARGET_TAG_NAME}" -F "${REL_NOTES}"

.github/workflows/cd.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "Run CD"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
# disable keyring (https://github.com/actions/runner-images/issues/6185):
10+
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
11+
12+
jobs:
13+
code-checks:
14+
uses: ./.github/workflows/checks.yml
15+
pre-release-check:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
TARGET_TAG_V: ${{ steps.version_check.outputs.TRGT_VERSION }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0 # for fetching tags, required for semantic-release
23+
- uses: ./.github/actions/setup-poetry
24+
- name: Check version of potential release
25+
id: version_check
26+
run: |
27+
TRGT_VERSION=$(poetry run semantic-release print-version)
28+
echo "TRGT_VERSION=${TRGT_VERSION}" >> $GITHUB_OUTPUT
29+
echo "${TRGT_VERSION}"
30+
- name: Check notes of potential release
31+
run: poetry run semantic-release changelog --unreleased
32+
release:
33+
needs: [code-checks, pre-release-check]
34+
if: needs.pre-release-check.outputs.TARGET_TAG_V != ''
35+
environment: auto-release
36+
runs-on: ubuntu-latest
37+
concurrency: release
38+
steps:
39+
- uses: actions/checkout@v4
40+
with:
41+
token: ${{ secrets.GH_PAT }}
42+
fetch-depth: 0 # for fetching tags, required for semantic-release
43+
- uses: ./.github/actions/setup-poetry
44+
- name: Run release script
45+
env:
46+
GH_TOKEN: ${{ secrets.GH_PAT }}
47+
TARGET_VERSION: ${{ needs.pre-release-check.outputs.TARGET_TAG_V }}
48+
CHGLOG_FILE: CHANGELOG.md
49+
run: ./.github/scripts/release.sh
50+
shell: bash

.github/workflows/checks.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
on:
2+
workflow_call:
3+
4+
env:
5+
CMAKE_BUILD_TYPE: Debug
6+
7+
jobs:
8+
run-checks:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
13+
steps:
14+
- uses: actions/checkout@v4
15+
# - name: Install dependencies [linux]
16+
# run: sudo apt-get install -y libldap-common
17+
# shell: bash
18+
- uses: ./.github/actions/setup-poetry
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install with poetry
22+
run: poetry install --all-extras
23+
- name: Run styling check
24+
run: poetry run pre-commit run --all-files
25+
- name: Testing
26+
run: |
27+
poetry run pytest ./tests/test_structs.py -v
28+
poetry run pytest ./tests/test_nlp.py -v
29+
poetry run pytest ./tests/test_glm.py -v
30+
- name: Build with poetry
31+
run: poetry build

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Run CI"
2+
3+
on:
4+
schedule: # will run only on the default branch (main)
5+
# Nightly build at 3:42 A.M.
6+
- cron: "42 3 */1 * *"
7+
pull_request:
8+
types: [opened, reopened]
9+
push:
10+
branches:
11+
- "**"
12+
- "!main"
13+
- "!gh-pages"
14+
15+
env:
16+
# disable keyring (https://github.com/actions/runner-images/issues/6185):
17+
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
18+
19+
jobs:
20+
code-checks:
21+
uses: ./.github/workflows/checks.yml
22+
build-wheels:
23+
uses: ./.github/workflows/wheels.yml
24+

.github/workflows/cmake.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: "Build and publish package"
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build-and-publish:
12+
uses: ./.github/workflows/wheels.yml
13+
secrets: inherit

.github/workflows/tests.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)