Repository navigation
185 lines (156 loc) · 6.1 KB
/
Copy pathversion.yml
File metadata and controls
185 lines (156 loc) · 6.1 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
174
175
176
177
178
179
180
181
182
183
184
185
name: Version Bump
on:
workflow_dispatch:
push:
branches:
- main
paths:
- ".changeset/**"
- '!.changeset/README.md'
jobs:
bump-version:
runs-on: ubuntu-latest
permissions:
contents: write # needed to commit the version bump and push the branch
pull-requests: write # needed to open the release PR
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: temurin
# Generated reference metadata uses Java 25, matching validation.
# The library still targets Java 17 via maven.compiler.release.
java-version: 25
- name: Detect change types and build PR body
id: detect
run: |
FILES=$(find .changeset -maxdepth 1 -type f ! -name README.md)
if [ -z "$FILES" ]; then
echo "No changeset files found"
echo "found=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "found=true" >> "$GITHUB_OUTPUT"
# Initialize variables
TYPE_PRIORITY=0
BODY=""
for FILE in $FILES; do
echo "Processing $FILE"
FILE_TYPE=$(grep '^type:' "$FILE" | awk '{print $2}')
case "$FILE_TYPE" in
patch) PRIORITY=1 ;;
minor) PRIORITY=2 ;;
major) PRIORITY=3 ;;
*) echo "Unknown type: $FILE_TYPE"; exit 1 ;;
esac
if [ $PRIORITY -gt $TYPE_PRIORITY ]; then
TYPE_PRIORITY=$PRIORITY
TYPE=$FILE_TYPE
fi
CONTENT=$(sed '/^type:/d' "$FILE" | sed '/^---$/d')
BODY="$BODY\n\n$CONTENT"
done
echo "TYPE=$TYPE" >> $GITHUB_ENV
echo "BODY<<EOF" >> $GITHUB_ENV
echo -e "$BODY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "Final detected type: $TYPE"
echo "PR body:"
echo -e "$BODY"
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
# Split the version by dots
IFS='.' read -r major minor patch <<< "$VERSION"
case "$TYPE" in
patch)
new_version="$major.$minor.$((patch+1))"
mvn versions:set -DnewVersion="$new_version" -DgenerateBackupPoms=false
;;
minor)
new_version="$major.$((minor+1)).0"
mvn versions:set -DnewVersion="$new_version" -DgenerateBackupPoms=false
;;
major)
new_version="$((major+1)).0.0"
mvn versions:set -DnewVersion="$new_version" -DgenerateBackupPoms=false
;;
*)
echo "Unknown type: $TYPE"; exit 1
;;
esac
mvn versions:commit
- name: Get new project version
id: get-version
if: steps.detect.outputs.found == 'true'
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "New version: $VERSION"
- name: Update CHANGELOG.md
if: steps.detect.outputs.found == 'true'
run: |
ENTRY_FILE=$(mktemp)
printf "## %s\n%s\n\n" "$VERSION" "$BODY" > "$ENTRY_FILE"
awk -v newfile="$ENTRY_FILE" '
BEGIN { fm=0; done=0 }
{
print
if ($0 == "---") {
fm++
if (fm == 2 && !done) {
print ""
while ((getline line < newfile) > 0) print line
done=1
}
}
}
' CHANGELOG.md > /tmp/CHANGELOG.new
mv /tmp/CHANGELOG.new CHANGELOG.md
# bump the index in the frontmatter to match the new entry count
sed -i "0,/^index: [0-9]*/s//index: $(( $(grep -c '^## ' CHANGELOG.md) ))/" CHANGELOG.md
- uses: actions/setup-python@v5
if: steps.detect.outputs.found == 'true'
with:
python-version: '3.12'
- name: Prepare versioned compatibility artifacts and catalogs
if: steps.detect.outputs.found == 'true'
run: |
python3 - <<'PY'
import json
import os
from pathlib import Path
path = Path("compatibility/browser-policy.json")
policy = json.loads(path.read_text(encoding="utf-8"))
version = os.environ["VERSION"]
policy["desktopVersion"] = version
if not policy["browserVersion"].startswith(version + "-browser."):
policy["browserVersion"] = version + "-browser.1"
path.write_text(json.dumps(policy, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
PY
./scripts/reference-docs.sh
python3 scripts/browser-compatibility.py
python3 scripts/release-catalogs.py
python3 scripts/browser-compatibility.py --check
python3 scripts/release-catalogs.py --check
- name: Delete changeset files
if: steps.detect.outputs.found == 'true'
run: |
find .changeset -type f ! -name 'README.md' -delete
echo "Removed processed changeset files."
- name: Create Pull Request
if: steps.detect.outputs.found == 'true'
uses: peter-evans/create-pull-request@v8
with:
base: main
commit-message: "chore: release v${{ env.VERSION }}"
branch: changeset
title: "Release v${{ env.VERSION }}"
body: |
${{ env.BODY }}
Compatibility artifacts and catalogs are prepared for `${{ env.VERSION }}`. Before merging, review the browser policy and synchronize `openpatch/online-ide` from this release branch:
```bash
scripts/sync-online-ide.sh /path/to/online-ide
```
The script also verifies the checkout. Commit and push the browser updates in online-ide and run its browser compatibility tests (`npm run test:browser`) before merging this PR. RELEASING.md has the full cross-repository runbook.
labels: version