-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·149 lines (123 loc) · 4.48 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·149 lines (123 loc) · 4.48 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
#!/bin/bash
# SPDX-FileCopyrightText: Provenant contributors
# SPDX-License-Identifier: Apache-2.0
# Release script that updates license data before releasing
# Usage: ./release.sh <patch|minor|major> [--execute]
set -euo pipefail
usage() {
echo "Usage: ./release.sh <patch|minor|major> [--execute]"
echo " --execute: Actually perform the release (default is dry-run)"
exit 1
}
confirm_execute() {
local response
printf "Proceed with %s release? [y/N] " "$RELEASE_TYPE"
read -r response
case "$response" in
y|Y|yes|YES)
;;
*)
echo "Release cancelled."
exit 1
;;
esac
}
run_release_step() {
local step="$1"
shift
if [ -n "$EXECUTE_FLAG" ]; then
cargo release "$step" "$@" --execute --no-confirm
else
cargo release "$step" "$@"
fi
}
case "${1:-}" in
patch|minor|major)
RELEASE_TYPE="$1"
;;
*)
usage
;;
esac
EXECUTE_FLAG=""
if [ "${2:-}" = "--execute" ]; then
EXECUTE_FLAG="--execute"
echo "⚠️ This will perform an actual release!"
confirm_execute
elif [ -n "${2:-}" ]; then
usage
else
echo "ℹ️ Dry-run mode (use --execute to perform actual release)"
fi
if [ -n "$(git status --porcelain)" ]; then
echo "⚠️ Working tree is not clean. Commit or stash changes before releasing."
exit 1
fi
echo "📦 Preparing for $RELEASE_TYPE release..."
# Update license data to latest before releasing
echo "📥 Updating license rules/licenses to latest version..."
if [ ! -e "reference/scancode-toolkit/.git" ]; then
echo "⚠️ Submodule not initialized. Run ./setup.sh first."
exit 1
fi
cd reference/scancode-toolkit
CURRENT_COMMIT=$(git rev-parse HEAD)
git fetch origin develop --depth=1
git -c advice.detachedHead=false checkout origin/develop
NEW_COMMIT=$(git rev-parse HEAD)
cd ../..
if [ "$CURRENT_COMMIT" != "$NEW_COMMIT" ]; then
echo "✅ License data updated: $CURRENT_COMMIT → $NEW_COMMIT"
else
echo "✅ License data already up to date"
fi
echo "🔎 Verifying ScanCode output format version sync..."
./scripts/check_scancode_output_format_sync.sh
echo "🔎 Verifying NOTICE attribution sync (retained upstream notices verbatim)..."
./scripts/check_notice_attribution_sync.sh --require-submodule
echo "🔎 Validating third-party license disclosure generation..."
if cargo about --version > /dev/null 2>&1; then
./scripts/generate_third_party_notices.sh /tmp/provenant-third-party-notices.md > /dev/null
echo "✅ Third-party license disclosure generates cleanly"
else
echo "⚠️ cargo-about not installed; skipping local disclosure validation (CI enforces it at release)."
echo " Install with: cargo install --locked cargo-about --features cli"
fi
echo "🔧 Regenerating embedded license index artifact..."
cargo run --manifest-path xtask/Cargo.toml --bin generate-index-artifact
if [ -n "$EXECUTE_FLAG" ] && [ "$CURRENT_COMMIT" != "$NEW_COMMIT" ]; then
git add reference/scancode-toolkit resources/license_detection/license_index.zst
git commit -s -m "chore: update license rules/licenses to latest"
echo "✅ Committed license data update"
elif [ -z "$EXECUTE_FLAG" ]; then
echo "ℹ️ Embedded license index artifact regenerated for validation (dry-run mode)"
git restore resources/license_detection/license_index.zst
if [ "$CURRENT_COMMIT" != "$NEW_COMMIT" ]; then
git restore reference/scancode-toolkit
fi
fi
echo "🚀 Running cargo-release versioning steps..."
run_release_step version "$RELEASE_TYPE"
run_release_step replace
run_release_step hook
echo "🔎 Verifying release version sync..."
./scripts/check_release_version_sync.sh
if [ -n "$EXECUTE_FLAG" ]; then
echo "📝 Creating DCO-signed release commit..."
git add -u
if git diff --cached --quiet; then
echo "⚠️ No release changes were staged for commit."
exit 1
fi
git commit -s -m "chore: release"
fi
echo "🏷️ Running cargo-release tag and push steps..."
run_release_step tag
run_release_step push
if [ -n "$EXECUTE_FLAG" ]; then
echo "✅ Release prep completed successfully!"
echo "ℹ️ The pushed release tag now triggers GitHub Actions to publish provenant-cli to crates.io and create GitHub release assets."
else
echo "✅ Dry-run release prep completed successfully!"
echo "ℹ️ In execute mode, the pushed release tag will trigger GitHub Actions to publish provenant-cli to crates.io and create GitHub release assets."
fi