Skip to content

Commit

Permalink
github actions added
Browse files Browse the repository at this point in the history
  • Loading branch information
hkir-dev committed Aug 1, 2024
1 parent 9a32004 commit 160bd15
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 7 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build_main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build schemas

# when main changed rebuild the products (schemas and documentations) and updates the build folder
on:
push:
branches: [ main ]

permissions: write-all

jobs:
build-and-publish:
name: Build main branch
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.9' ]
steps:

- uses: actions/checkout@v3
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Install dependencies
run: |
poetry install
- name: Generate merged schemas
run: |
cp src/cell_annotation_schema/schema/cell_annotation_schema.yaml build/general_schema.yaml
gen-linkml src/cell_annotation_schema/schema/BICAN/BICAN_schema.yaml --output build/BICAN_schema.yaml --mergeimports --format yaml --no-materialize-attributes
gen-linkml src/cell_annotation_schema/schema/CAP/CAP_schema.yaml --output build/CAP_schema.yaml --mergeimports --format yaml --no-materialize-attributes
- name: Commit files
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git diff --quiet && git diff --staged --quiet || git commit -a -m "Main branch build"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.P_TOKEN }}
branch: ${{ github.head_ref }}
56 changes: 56 additions & 0 deletions .github/workflows/nightly_snapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Nightly Snapshot

on:
schedule:
- cron: "59 23 * * *"
workflow_dispatch:

permissions:
contents: write

jobs:
tag:
name: Make snapshot release
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.9' ]
steps:
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Install dependencies
run: |
poetry install
- name: Generate merged schemas
run: |
cp src/cell_annotation_schema/schema/cell_annotation_schema.yaml build/general_schema.yaml
gen-linkml src/cell_annotation_schema/schema/BICAN/BICAN_schema.yaml --output build/BICAN_schema.yaml --mergeimports --format yaml --no-materialize-attributes
gen-linkml src/cell_annotation_schema/schema/CAP/CAP_schema.yaml --output build/CAP_schema.yaml --mergeimports --format yaml --no-materialize-attributes
- name: Make Snapshot
uses: ncipollo/release-action@v1
with:
artifacts: "build/general_schema.yaml,
build/BICAN_schema.yaml,build/CAP_schema.yaml"
body: "Nightly snapshot release. Draft only, please use a stable release instead."
allowUpdates: true
draft: true
makeLatest: false
name: "${{ steps.date.outputs.date }} SNAPSHOT"
removeArtifacts: true
tag: "snapshot"
29 changes: 23 additions & 6 deletions .github/workflows/pypi-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,31 @@ jobs:
pipx install poetry
poetry self add "poetry-dynamic-versioning[plugin]"
# - name: Install dependencies
# run: poetry install --no-interaction
- name: Install dependencies
run: poetry install --no-interaction

- name: Generate merged schemas
run: |
cp src/cell_annotation_schema/schema/cell_annotation_schema.yaml build/general_schema.yaml
gen-linkml src/cell_annotation_schema/schema/BICAN/BICAN_schema.yaml --output build/BICAN_schema.yaml --mergeimports --format yaml --no-materialize-attributes
gen-linkml src/cell_annotation_schema/schema/CAP/CAP_schema.yaml --output build/CAP_schema.yaml --mergeimports --format yaml --no-materialize-attributes
- name: Package release assets
run: |
mkdir -p src/cell_annotation_schema/schemas
touch src/cas_schema/schemas/__init__.py
cp build/general_schema.yaml src/cell_annotation_schema/schemas
cp build/BICAN_schema.yaml src/cell_annotation_schema/schemas
cp build/CAP_schema.yaml src/cell_annotation_schema/schemas
- name: Update package version
run: |
sed -i 's/__version__/${{ github.ref_name }}/g' pyproject.toml
- name: Build source and wheel archives
run: poetry build

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@v1.2.2
- name: Publish Package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
password: ${{ secrets.PYPI_API_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/pypi-test-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
name: Publish Python Package

on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9

- name: Install Poetry
run: |
pipx install poetry
poetry self add "poetry-dynamic-versioning[plugin]"
- name: Install dependencies
run: poetry install --no-interaction

- name: Generate merged schemas
run: |
cp src/cell_annotation_schema/schema/cell_annotation_schema.yaml build/general_schema.yaml
gen-linkml src/cell_annotation_schema/schema/BICAN/BICAN_schema.yaml --output build/BICAN_schema.yaml --mergeimports --format yaml --no-materialize-attributes
gen-linkml src/cell_annotation_schema/schema/CAP/CAP_schema.yaml --output build/CAP_schema.yaml --mergeimports --format yaml --no-materialize-attributes
- name: Package release assets
run: |
mkdir -p src/cell_annotation_schema/schemas
touch src/cas_schema/schemas/__init__.py
cp build/general_schema.yaml src/cell_annotation_schema/schemas
cp build/BICAN_schema.yaml src/cell_annotation_schema/schemas
cp build/CAP_schema.yaml src/cell_annotation_schema/schemas
- name: Update package version
run: |
sed -i 's/__version__/${{ github.ref_name }}/g' pyproject.toml
- name: Build source and wheel archives
run: poetry build

- name: Publish Package
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cell_annotation_schema"
version = "1.1.0"
version = "__version__"
description = "General, open-standard schema for cell annotations"
authors = ["Huseyin Kir <[email protected]>"]
license = "GNU GPL v3.0"
Expand Down

0 comments on commit 160bd15

Please sign in to comment.