Skip to content

Commit fd5b6ff

Browse files
authored
Merge pull request #237 from ralfhandl/contributing-release-steps
2 parents 0e9d11f + b9bb8a3 commit fd5b6ff

File tree

5 files changed

+191
-17
lines changed

5 files changed

+191
-17
lines changed

CONTRIBUTING.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The `main` branch holds
4242
- sources for work-in-progress schema versions in `schemas/vX.Y-dev` folders and their tests in `tests/vX.Y-dev` folders,
4343
- utility scripts and supporting documentation.
4444

45-
Other branches are usually short-lived, for example and for maintaining utility scripts.
45+
Other branches are usually short-lived, for example for maintaining utility scripts.
4646

4747
### Reviewers
4848

@@ -75,6 +75,60 @@ Produce stand-alone HTML files for all work-in-progress specifications in the lo
7575
npm run build-dev
7676
```
7777

78+
## Publishing
79+
80+
### Specification Versions
81+
82+
The specification versions are published to the [spec site](https://spec.openapis.org) by creating an `vX.Y.Z-rel` branch where `versions/X.Y.Z-dev.md` is renamed to `versions/X.Y.Z.md` and then merged into `main`.
83+
This renaming preserves the commit history when using `git log --follow`.
84+
85+
The steps for creating a `vX.Y.Z-rel` branch are:
86+
87+
1. Update `EDITORS.md` in a temporary branch and merge changes back into `main` via pull request
88+
2. Prepare spec files in a temporary branch:
89+
- `npm run format-markdown`
90+
- `npm run build-dev`
91+
- open `deploy-preview/X.Y.Z-dev.html` in browser and verify correct formatting
92+
- adjust and repeat until done
93+
- merge changes back into `main` via pull request
94+
3. Create branch `vX.Y.Z-rel` from `main` in the OAI/Overlay-Specification repo and adjust it
95+
- the bash script `scripts/adjust-release-branch.sh` does this:
96+
- move file `versions/X.Y.Z-dev.md` to `versions/X.Y.Z.md` and replace the release date placeholder `| TBD |` in the history table of Appendix A with the current date
97+
- copy file `EDITORS.md` to `versions/X.Y.Z-editors.md`
98+
- for an X.Y.0 release
99+
- move folder `schemas/vX.Y-dev` to `schemas/vX.Y`
100+
- move folder `tests/vX.Y-dev` to `tests/vX.Y`
101+
4. Commit, push, and merge `vX.Y.Z-rel` into `main` via pull request
102+
5. Archive branch `vX.Y.Z-rel`
103+
104+
HTML renderings of the specification versions are generated from the `versions` folder on `main` by the `respec` workflow on changes to files in that folder, which generates a pull request for publishing the HTML renderings to the [spec site](https://spec.openapis.org/overlay). The workflow can be run manually if required.
105+
106+
Schema iterations are generated from the YAML source files in `schemas/vX.Y` by converting them to JSON, renaming to the relevant last-changed dates, and replacing the `WORK-IN-PROGRESS` placeholders with these dates. This is done by the `schema-publish` workflow on changes to files in these folders, which generates a pull request for publishing the new schema iterations to the [spec site](https://spec.openapis.org/overlay). The workflow can be run manually if required.
107+
108+
#### Start Next Patch Version
109+
110+
Once the released specification version is published, the next patch version X.Y.(Z+1) can be started:
111+
112+
1. Run bash script `scripts/start-release.sh X.Y.(Z+1)` in branch `main` to
113+
- create branch `start-X.Y.(Z+1)`
114+
- initialize `versions/X.Y.(Z+1)-dev.md` with empty history and content from `versions/X.Y.Z.md`
115+
- change version heading to X.Y.(Z+1) and add a new line to the version history table in Appendix A
116+
- commit changes
117+
2. Push branch `start-X.Y.(Z+1)` and merge into `main` via pull request
118+
119+
#### Start New Minor or Major Version
120+
121+
A new minor version X.(Y+1).0 or major version (X+1).0.0 is started similarly:
122+
123+
1. Run bash script `scripts/start-release.sh X'.Y'.0` in branch `main` to
124+
- create branch `start-X'.Y'.0`
125+
- initialize `versions/X'.Y'.0-dev.md` with empty history and content from `versions/X.Y.Z.md`
126+
- change version heading to X'.Y'.0 and add a new line to the version history table in Appendix A
127+
- copy schema files `schemas/vX.Y` to `schemas/vX'.YY'-dev` and change version in all schema files
128+
- copy schema tests `tests/vX.Y` to `tests/vX'.YY'-dev` and change version in all test files
129+
- commit changes
130+
2. Push branch `start-X'.Y'.0` and merge into `main` via pull request
131+
78132
## Style guide for Overlay Specification
79133

80134
Some terminology and when to use it:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"scripts": {
4242
"build": "bash ./scripts/md2html/build.sh",
4343
"build-dev": "npm run validate-markdown && bash ./scripts/md2html/build.sh dev && bash ./scripts/schema-publish.sh dev",
44-
"format-markdown": "bash ./scripts/format-markdown.sh *.md schemas/**/*.md versions/*.md",
44+
"format-markdown": "npx markdownlint-cli2 --fix *.md schemas/**/*.md versions/*-dev.md",
4545
"validate-markdown": "markdownlint-cli2 *.md schemas/**/*.md versions/*.md && linkspector check",
4646
"test": "c8 --100 vitest run --coverage"
4747
}

scripts/adjust-release-branch.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
# Author: @ralfhandl
4+
5+
# Run this script from the root of the repo. It is designed to be run manually in a release branch.
6+
7+
branch=$(git branch --show-current)
8+
today=$(date +%Y-%m-%d)
9+
10+
if [[ ! $branch =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rel$ ]]; then
11+
echo "This script is intended to be run from a release branch, e.g. v1.1.0-rel"
12+
exit 1
13+
fi
14+
15+
vVersion=$(basename "$branch" "-rel")
16+
version=${vVersion:1}
17+
echo Prepare release of $version
18+
19+
# create snapshot of current editors
20+
cp EDITORS.md versions/$version-editors.md
21+
22+
# "move" dev version of spec to release version - git will treat this as a rename
23+
# Replace release date placeholder with current date - should only appear in the history table
24+
sed "s/| TBD |/| $today |/g" versions/$version-dev.md > versions/$version.md
25+
# show what changed in the spec - should only be the history table line for the current release
26+
diff -Z versions/$version-dev.md versions/$version.md
27+
# remove dev version of spec
28+
rm versions/$version-dev.md
29+
30+
# rename schemas dev folder and tests folder if present
31+
vMinor=$(echo $vVersion | cut -d. -f1,2)
32+
if [ -d "schemas/$vMinor-dev" ]; then
33+
mv "schemas/$vMinor-dev" "schemas/$vMinor"
34+
fi
35+
if [ -d "tests/$vMinor-dev" ]; then
36+
mv "tests/$vMinor-dev" "tests/$vMinor"
37+
fi

scripts/format-markdown.sh

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

scripts/start-release.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/usr/bin/env bash
2+
3+
# Author: @ralfhandl
4+
5+
# Run this script from the root of the repo. It is designed to be run manually in the main branch.
6+
7+
if [[ ! $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
8+
echo "Usage: $0 <nextVersion>"
9+
echo "Example: $0 1.1.1"
10+
exit 1
11+
fi
12+
13+
nextVersion=$1
14+
minor=$(echo $nextVersion | cut -d. -f1,2)
15+
nextPatch=$(echo $nextVersion | cut -d. -f3)
16+
17+
# Find last published spec version for this minor version
18+
lastSpec=$(ls -1 versions/*.md | grep -E "/$minor\.[0-9].md" | tail -1)
19+
20+
if [ -z "$lastSpec" ]; then
21+
# Find last published spec version
22+
lastSpec=$(ls -1 versions/*.md | grep -E "/.+\.[0-9].md" | tail -1)
23+
releaseType="Release"
24+
else
25+
lastPatch=$(basename "$lastSpec" ".md" | cut --delimiter=. --fields=3)
26+
releaseType="Patch release"
27+
fi
28+
29+
if [ -z "$lastSpec" ]; then
30+
echo "Could not find any published specification version"
31+
exit 1
32+
fi
33+
34+
lastVersion=$(basename "$lastSpec" ".md")
35+
echo === Initialize src/oas.md for $nextVersion from $lastVersion
36+
37+
# Create PR branch from development branch
38+
branch=$(git branch --show-current)
39+
prBranch="start-$nextVersion"
40+
if ! git checkout -b "$prBranch"; then
41+
echo "=== Failed: PR branch $prBranch already exists locally, please delete it and try again"
42+
exit 1
43+
fi
44+
45+
# create dev version of spec from last published spec
46+
temp=$(mktemp)
47+
48+
# bump version headline, add line to history table
49+
historyTableHeader="\n| Version | Date | Notes |\n| ---- | ---- | ---- |\n"
50+
sed -z -e "s/\n## Version $lastVersion\n/\n## Version $nextVersion\n/" \
51+
-z -e "s/$historyTableHeader/$historyTableHeader| $nextVersion | TBD | $releaseType of the Overlay Specification $nextVersion |\n/" \
52+
"$lastSpec" > versions/$nextVersion-dev.md
53+
54+
git add versions/$nextVersion-dev.md
55+
git commit -m "initialize $nextVersion from $lastVersion"
56+
57+
echo === Initialized versions/$nextVersion-dev.md
58+
59+
# when starting a new major or minor version
60+
if [ "$nextPatch" == "0" ]; then
61+
lastMinor=$(echo "$lastVersion" | cut -d . -f 1,2)
62+
63+
echo === Initialize schemas for new version $minor
64+
cp -r "schemas/v$lastMinor" "schemas/v$minor-dev"
65+
66+
minorRegex=$(echo "$minor" | sed 's/\./\\\\\\./')
67+
lastMinorRegex=$(echo "$lastMinor" | sed 's/\./\\\\\\./')
68+
69+
for file in schemas/v$minor-dev/*.yaml; do
70+
sed -e "s/$lastMinor/$minor/g" \
71+
-e "s/\^$lastMinorRegex\\\./\^$minorRegex\\\./g" \
72+
"$file" > "$temp"
73+
mv -f "$temp" "$file"
74+
done
75+
76+
for file in schemas/v$minor-dev/*.md; do
77+
sed -e "s/$lastMinor/$minor/g" \
78+
"$file" > "$temp"
79+
mv -f "$temp" "$file"
80+
done
81+
82+
echo === Initialize tests for new version $minor
83+
cp -r "tests/v$lastMinor" "tests/v$minor-dev"
84+
85+
for file in tests/v$minor-dev/{pass,fail}/*.yaml; do
86+
sed -e "s/$lastMinor/$minor/g" "$file" > "$temp"
87+
mv -f "$temp" "$file"
88+
done
89+
90+
git add schemas/v$minor-dev tests/v$minor-dev
91+
git commit -m "adjust schemas, test script, and test data"
92+
93+
echo === Adjusted schemas and tests
94+
fi
95+
96+
# Clean up
97+
git switch "$branch"
98+
echo === Done

0 commit comments

Comments
 (0)