-
Notifications
You must be signed in to change notification settings - Fork 21
84 lines (80 loc) · 3.28 KB
/
validate_and_release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# - validate the protocol and activities in the repo with reproschema.py
# - triggers a release when a github release is published
name: validate and release
on:
push:
branches:
- main
pull_request:
branches: ['*']
# Allow to trigger the generation of release files automatically
workflow_dispatch:
inputs:
version:
description: 'version number'
required: true
type: string
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dependencies
# TODO This installs reproschema from source and not from pypi
# This may not be the optimal way of doing it.
run: |
python -m pip install --upgrade pip setuptools
pip install git+https://github.com/ReproNim/reproschema-py.git
- name: Validate content
run: |
python scripts/jsonParser.py
reproschema validate examples
release:
needs: [validate]
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install linkml astor pre-commit
pip install git+https://github.com/ReproNim/reproschema-py.git
- name: Generate pydantic using linml and fixing it with reproschema specific script
run: |
gen-pydantic --pydantic-version 2 linkml-schema/reproschema.yaml > reproschema_model.py
python scripts/fix_pydantic.py reproschema_model.py
pre-commit run --files reproschema_model.py || true
- name: Generate jsonld format using linkml
run: |
gen-jsonld --context https://raw.githubusercontent.com/ReproNim/reproschema/main/contexts/reproschema linkml-schema/reproschema.yaml > reproschema.jsonld
- name: Generate n-triples and turtle formats using reproschema
run: |
reproschema convert --format n-triples reproschema.jsonld > reproschema.nt
reproschema convert --format turtle reproschema.jsonld > reproschema.ttl
- name: Make a release
run: |
echo "Making a release ${{ inputs.version }}"
mkdir releases/${{ inputs.version }}
cp contexts/reproschema releases/${{ inputs.version }}/reproschema
mv reproschema_model.py releases/${{ inputs.version }}/reproschema_model.py
mv reproschema.jsonld releases/${{ inputs.version }}/reproschema.jsonld
mv reproschema.nt releases/${{ inputs.version }}/reproschema.nt
mv reproschema.ttl releases/${{ inputs.version }}/reproschema.ttl
- name: Open pull requests to add files
uses: peter-evans/create-pull-request@v7
with:
commit-message: "[REL] adding files to for release ${{ inputs.version }}"
base: main
token: ${{ secrets.GITHUB_TOKEN }}
delete-branch: true
title: "[REL] adding files to for release ${{ inputs.version }}"
body: done via this [GitHub Action](https://github.com/${{ github.repository_owner }}/reproschema/blob/main/.github/workflows/validate_and_release.yml)