|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Recovery script for the v0.2.0 post-release housekeeping. The |
| 3 | +# original scripts/post-release-issues.sh halted partway through |
| 4 | +# because gh rejected an unknown label. This version is robust: |
| 5 | +# |
| 6 | +# - Creates the missing labels first (idempotent). |
| 7 | +# - Skips issues whose title already exists. |
| 8 | +# - Continues past individual failures. |
| 9 | +# - Closes issues immediately after creation since the underlying |
| 10 | +# work has been merged on main as of v0.3.0-SNAPSHOT. |
| 11 | +# - Creates the v0.2.0 GitHub Release if missing. |
| 12 | +# |
| 13 | +# Run from a host where `gh auth status` is logged in: |
| 14 | +# |
| 15 | +# ./scripts/post-release-fix.sh |
| 16 | +# |
| 17 | +# After it succeeds, this script can be deleted. |
| 18 | + |
| 19 | +set -uo pipefail # NOT -e: continue past individual failures. |
| 20 | + |
| 21 | +REPO="OpenHistoricalMap/edtf-java" |
| 22 | + |
| 23 | +ensure_label() { |
| 24 | + local name="$1" desc="$2" color="$3" |
| 25 | + if ! gh label list -R "$REPO" --search "$name" --json name --jq '.[].name' \ |
| 26 | + | grep -Fxq "$name"; then |
| 27 | + echo "Creating label: $name" |
| 28 | + gh label create "$name" -R "$REPO" --description "$desc" --color "$color" |
| 29 | + else |
| 30 | + echo "Label exists: $name" |
| 31 | + fi |
| 32 | +} |
| 33 | + |
| 34 | +# Find an open issue by exact title; print its number, or empty. |
| 35 | +issue_number_by_title() { |
| 36 | + local title="$1" |
| 37 | + gh issue list -R "$REPO" --state all --search "in:title \"$title\"" \ |
| 38 | + --json number,title \ |
| 39 | + --jq ".[] | select(.title == \"$title\") | .number" | head -1 |
| 40 | +} |
| 41 | + |
| 42 | +create_or_skip() { |
| 43 | + local title="$1" labels="$2" body="$3" |
| 44 | + local existing |
| 45 | + existing=$(issue_number_by_title "$title") |
| 46 | + if [[ -n "$existing" ]]; then |
| 47 | + echo "Issue exists: #$existing $title — skipping create" |
| 48 | + echo "$existing" |
| 49 | + return |
| 50 | + fi |
| 51 | + echo "Creating issue: $title" |
| 52 | + local url |
| 53 | + url=$(gh issue create -R "$REPO" --title "$title" --label "$labels" --body "$body") |
| 54 | + # Extract the issue number from the URL. |
| 55 | + echo "${url##*/}" |
| 56 | +} |
| 57 | + |
| 58 | +close_with_comment() { |
| 59 | + local number="$1" comment="$2" |
| 60 | + if [[ -z "$number" ]]; then return; fi |
| 61 | + gh issue close "$number" -R "$REPO" \ |
| 62 | + --reason completed --comment "$comment" || true |
| 63 | +} |
| 64 | + |
| 65 | +# 1. Labels. |
| 66 | +ensure_label enhancement "New feature or request" a2eeef |
| 67 | +ensure_label testing "Tests, vectors, smoke checks" 0e8a16 |
| 68 | + |
| 69 | +# 2. The three follow-up issues. All three are now complete on main, |
| 70 | +# so each is created (or matched) and then closed with a pointer |
| 71 | +# to the merging commit. |
| 72 | + |
| 73 | +n1=$(create_or_skip \ |
| 74 | + "Add locale-aware formatting (ResourceBundle / Transifex)" \ |
| 75 | + "enhancement" \ |
| 76 | + "Closed by 0a283cc: EdtfFormatter in io.github.openhistoricalmap.edtf.format with English ResourceBundle and 21 unit tests. Default locale + per-locale variants supported. See CHANGELOG.md v0.3.0 entry.") |
| 77 | + |
| 78 | +n2=$(create_or_skip \ |
| 79 | + "Add Ant/Ivy consumption smoke test against a JOSM plugin" \ |
| 80 | + "enhancement,testing" \ |
| 81 | + "Closed by 1d79c23 + 5d52c16: smoke/ project resolves the published artefact via Ivy from Maven Central, compiles src/Smoke.java against it, and asserts on stdout. .github/workflows/smoke.yml runs it daily. See smoke/README.md.") |
| 82 | + |
| 83 | +n3=$(create_or_skip \ |
| 84 | + "Add LoC spec, ISO 8601-2, and edge-case test vector TSVs" \ |
| 85 | + "enhancement,testing" \ |
| 86 | + "Closed by e742539: loc-spec.tsv, iso8601-2.tsv, and edge-cases.tsv added under src/test/resources/vectors/, with three new @TestFactory methods in GeneratedVectorsTest.") |
| 87 | + |
| 88 | +close_with_comment "$n1" "Closed by 0a283cc; shipped in v0.3.0." |
| 89 | +close_with_comment "$n2" "Closed by 1d79c23 + 5d52c16; shipped in v0.3.0." |
| 90 | +close_with_comment "$n3" "Closed by e742539; shipped in v0.3.0." |
| 91 | + |
| 92 | +# 3. The v0.2.0 GitHub Release. |
| 93 | +if gh release view v0.2.0 -R "$REPO" >/dev/null 2>&1; then |
| 94 | + echo "Release v0.2.0 already exists — skipping." |
| 95 | +else |
| 96 | + echo "Creating release v0.2.0" |
| 97 | + gh release create v0.2.0 -R "$REPO" \ |
| 98 | + --title "v0.2.0 — L0 + L1 + L2 EDTF parsing" \ |
| 99 | + --notes "$(cat <<'EOF' |
| 100 | +First public release on Maven Central. Covers EDTF Levels 0, 1, and |
| 101 | +most of Level 2. |
| 102 | +
|
| 103 | +**Maven Central**: <https://central.sonatype.com/artifact/io.github.openhistoricalmap/edtf/0.2.0> |
| 104 | +**Javadoc**: <https://javadoc.io/doc/io.github.openhistoricalmap/edtf/0.2.0> |
| 105 | +
|
| 106 | +See [CHANGELOG.md](https://github.com/OpenHistoricalMap/edtf-java/blob/main/CHANGELOG.md) |
| 107 | +for the full record, including the four documented divergences from |
| 108 | +edtf.js. |
| 109 | +
|
| 110 | +## What's included |
| 111 | +
|
| 112 | +- **Level 0**: ISO 8601-1 dates, datetimes, centuries. |
| 113 | +- **Level 1**: uncertain / approximate / mixed markers, Y-notation, |
| 114 | + seasons (codes 21-24), open / unknown intervals. |
| 115 | +- **Level 2**: non-progressive partial X-masks, sets and lists with |
| 116 | + consecutive `start..end` members, extended seasons (25-41), |
| 117 | + three-digit decade notation, Y exponential and significant-digits |
| 118 | + forms, positional UA markers on individual date components. |
| 119 | +- 247 unit tests, including a generated parity-vector harness |
| 120 | + against `edtf.js` v4.11.0. |
| 121 | +- Java 17 bytecode target, zero runtime dependencies, JPMS module |
| 122 | + descriptor. |
| 123 | +
|
| 124 | +## Documented divergences from edtf.js |
| 125 | +
|
| 126 | +1. Datetime canonical form normalised to UTC. |
| 127 | +2. Datetime atomicity: minute/second/millisecond precision report `min == max`. |
| 128 | +3. Season codes 21-24 use calendar-quarter bounds. |
| 129 | +4. Consecutive list members report `start.min..end.max`. |
| 130 | +EOF |
| 131 | +)" |
| 132 | +fi |
| 133 | + |
| 134 | +echo "" |
| 135 | +echo "Done." |
| 136 | +echo " Issues: https://github.com/${REPO}/issues?q=is%3Aissue" |
| 137 | +echo " Releases: https://github.com/${REPO}/releases" |
0 commit comments