Skip to content

Commit b9bb8a3

Browse files
committed
Start release
1 parent fc63641 commit b9bb8a3

File tree

2 files changed

+115
-19
lines changed

2 files changed

+115
-19
lines changed

CONTRIBUTING.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ npm run build-dev
7979

8080
### Specification Versions
8181

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 to `main`.
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`.
8383
This renaming preserves the commit history when using `git log --follow`.
8484

8585
The steps for creating a `vX.Y.Z-rel` branch are:
@@ -98,38 +98,36 @@ The steps for creating a `vX.Y.Z-rel` branch are:
9898
- for an X.Y.0 release
9999
- move folder `schemas/vX.Y-dev` to `schemas/vX.Y`
100100
- move folder `tests/vX.Y-dev` to `tests/vX.Y`
101-
4. Merge `vX.Y.Z-rel` into `main` via pull request
101+
4. Commit, push, and merge `vX.Y.Z-rel` into `main` via pull request
102102
5. Archive branch `vX.Y.Z-rel`
103103

104104
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.
105105

106106
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.
107107

108-
<!-- #### Start Next Patch Version
108+
#### Start Next Patch Version
109109

110110
Once the released specification version is published, the next patch version X.Y.(Z+1) can be started:
111111

112-
1. Run bash script `scripts/start-release.sh` in branch `main` to
113-
- create branch `vX.Y-dev-start-X.Y.(Z+1)`
114-
- initialize `src/oas.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 of `src/oas.md`
116-
- commit and push changes
117-
2. Merge changes into `main` via pull request
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
118118

119119
#### Start New Minor or Major Version
120120

121121
A new minor version X.(Y+1).0 or major version (X+1).0.0 is started similarly:
122122

123-
1. Create branch `vX'.Y'-dev` from `vX.Y-dev`
124-
2. Run bash script `scripts/start-release.sh` in the new branch to
125-
- create branch `vX'.Y'-dev-start-X'.Y'.0`
126-
- initialize `src/oas.md` with empty history and content from `versions/X.Y.Z.md`
127-
- change version heading to X'.Y'.0 and add a new line to the version history table in Appendix A of `src/oas.md`
128-
- change version in all schema files `src/schemas/validation/.yaml`
129-
- change version in schema test script `tests/schema/schema.test.mjs`
130-
- change version in schema test fixtures in folders `tests/schema/pass` and `tests/schema/fail`
131-
- commit and push changes
132-
3. Merge `vX'.Y'-dev-start-X'.Y'.0` into `vX'.Y'-dev` via pull request -->
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
133131

134132
## Style guide for Overlay Specification
135133

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)