Repository navigation
173 lines (156 loc) · 8.04 KB
/
Copy pathrelease.yml
File metadata and controls
173 lines (156 loc) · 8.04 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# ==============================================================================
# WORKFLOW: Release Ontology
# ==============================================================================
# Purpose: Stamp release version into artifacts, create a GitHub release with
# attached serialization artifacts, and trigger documentation rebuild.
#
# ┌─────────────────────────────────────────────────────────────────────┐
# │ What this workflow does │
# │ ───────────────────────────────────────────────────────────────── │
# │ 1. Validates semver tag format (replaces enforce-tags.yml) │
# │ 2. Stamps owl:versionIRI and owl:versionInfo into all artifacts │
# │ using ROBOT annotate — no ODK rebuild (qc.yml owns that) │
# │ versionIRI: <ontbase>/<version> (PMDco convention) │
# │ e.g. https://w3id.org/pmd/log/1.0.0 │
# │ 3. Commits stamped artifacts back to main │
# │ 4. Creates a git tag v<version> pointing to that commit │
# │ 5. Creates a GitHub release with OWL / TTL attached │
# │ 6. Dispatches trigger-docs so docs.yml rebuilds versioned docs │
# └─────────────────────────────────────────────────────────────────────┘
#
# Triggers:
# Manual only — Actions → Release Ontology → Run workflow → enter version
#
# Version format: semver without the "v" prefix (e.g. 1.0.0, 2.1.3)
#
# Execution chain:
# [this] → docs (versioned Widoco build + GitHub Pages deploy)
# ==============================================================================
name: Release Ontology
on:
workflow_dispatch:
inputs:
version:
description: Release version — semver X.Y.Z without v prefix (e.g. 1.0.0). Becomes owl:versionIRI ontbase/1.0.0.
required: true
type: string
release_notes:
description: Release notes (markdown). Leave empty to auto-generate from commits.
required: false
type: string
default: ""
permissions:
contents: write
jobs:
release:
name: Build & Release
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.6
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check ontology scaffold exists
run: |
if [ ! -d "src/ontology" ] || [ ! -f "src/ontology/Makefile" ]; then
echo "::error::src/ontology not found. Run the Setup New Ontology workflow first."
exit 1
fi
# ── Validate and resolve version ─────────────────────────────────────
- name: Resolve version
id: version
run: |
VERSION="${{ inputs.version }}"
echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$' || {
echo "::error::Version '$VERSION' is not valid semver (expected X.Y.Z)"
exit 1
}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Releasing version: $VERSION"
# ── Guard: fail early if release already exists ───────────────────────
- name: Check release does not already exist
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
if gh release view "v${VERSION}" > /dev/null 2>&1; then
echo "::error::Release v${VERSION} already exists. Delete it and the tag first."
exit 1
fi
# ── Stamp versionIRI into all release artifacts ───────────────────────
# qc.yml owns the full ODK rebuild on push to main.
# The release workflow only stamps the correct semver versionIRI
# onto the already-built committed artifacts using ROBOT annotate.
# ──────────────────────────────────────────────────────────────────────
- name: Stamp version into artifacts
run: |
VERSION="${{ steps.version.outputs.version }}"
ODK_YAML=$(find src/ontology -maxdepth 1 -name "*-odk.yaml" | head -1)
ONT_ID=$(python3 -c "import yaml; d=yaml.safe_load(open('$ODK_YAML')); print(d['id'])")
URIBASE=$(python3 -c "import yaml; d=yaml.safe_load(open('$ODK_YAML')); print(d['uribase'])")
ONTBASE="${URIBASE}/${ONT_ID}"
for f in $(find src/ontology -maxdepth 1 -name "*.owl" \
! -name "*-edit.owl" ! -name "*-idranges.owl"); do
robot annotate \
--input "$f" \
--version-iri "${ONTBASE}/${VERSION}" \
--annotation owl:versionInfo "${VERSION}" \
--output "$f"
TTL="${f%.owl}.ttl"
[ -f "$TTL" ] && robot annotate \
--input "$TTL" \
--version-iri "${ONTBASE}/${VERSION}" \
--annotation owl:versionInfo "${VERSION}" \
--output "$TTL"
done
# ── Commit stamped artifacts ──────────────────────────────────────────
- name: Commit release artifacts
uses: EndBug/add-and-commit@v9
with:
message: Release v${{ steps.version.outputs.version }}
cwd: .
add: src/ontology/*.owl src/ontology/*.ttl
default_author: github_actions
push: true
# ── Create git tag ────────────────────────────────────────────────────
- name: Create git tag
run: |
VERSION="${{ steps.version.outputs.version }}"
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git tag "v${VERSION}" 2>/dev/null && git push origin "v${VERSION}" || \
echo "Tag v${VERSION} already exists — skipping."
# ── Create GitHub release ─────────────────────────────────────────────
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
NOTES="${{ inputs.release_notes }}"
ASSETS=$(find src/ontology -maxdepth 1 \( -name "*.owl" -o -name "*.ttl" \) \
! -name "*-edit.owl" | tr '\n' ' ')
if [ -z "$ASSETS" ]; then
echo "::error::No release artifacts found in src/ontology/"
exit 1
fi
echo "Attaching assets: $ASSETS"
if [ -n "$NOTES" ]; then
gh release create "v${VERSION}" \
--title "Release v${VERSION}" \
--notes "$NOTES" \
--generate-notes \
$ASSETS
else
gh release create "v${VERSION}" \
--title "Release v${VERSION}" \
--generate-notes \
$ASSETS
fi
# ── Trigger versioned documentation build ────────────────────────────
- name: Trigger versioned documentation build
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: trigger-docs
client-payload: '{"version": "${{ steps.version.outputs.version }}"}'