-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrelease_skip.sh
More file actions
executable file
·203 lines (162 loc) · 7.55 KB
/
release_skip.sh
File metadata and controls
executable file
·203 lines (162 loc) · 7.55 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/bash -ex
#
# This script will coorinate releasing a binary artifact of:
# https://github.com/skiptools/skiptool.git
# which will be published to the plug-in repository's releases:
# https://github.com/skiptools/skip/releases
#
# The https://github.com/skiptools/skip.git repository
# will be tagged with the next semantic version up from
# its last tag.
#
# To make a patch release (like 1.0.2 -> 1.0.3), run:
#
# ./scripts/release_skip.sh
#
# To make a minor release (like 1.0.2 -> 1.1.0):
#
# SEMVER_BUMP='minor' ./scripts/release_skip.sh
#
# To make a major release (like 1.0.2 -> 2.0.0):
#
# SEMVER_BUMP='major' ./scripts/release_skip.sh
# cannot run unless there are currently no diffs; override by running:
# SKIPDIFF=true ./scripts/release_skip.sh
#eval ${SKIPDIFF:-"git diff --exit-code"}
set -o pipefail
# get latest skip
git pull || true
swift package update
CONFIGURATION=${CONFIGURATION:-"release"}
PRODUCT=SkipRunner
SKIPCMD=skip
# name the artifact the same as the tool
ARTIFACT=${SKIPCMD}
ARTIFACTBUNDLE="${ARTIFACT}.artifactbundle"
PLUGIN_MACOS_ZIP="${ARTIFACT}-macos.zip"
PLUGIN_LINUX_ZIP="${ARTIFACT}-linux.zip"
GITDATE="$(git log -1 --format=%ad --date=iso-strict)"
GITREF="$(git rev-parse HEAD)"
RELSTAGING=`mktemp -d`
# the relative path to the repo that hosts the plug-in code
# and references the binary executable
SKIPPKG="../skip/Package.swift"
SKIPSTONEDIR="../skipstone"
SKIPPKGDIR=$(dirname ${SKIPPKG})
SKIPBREWDIR="../homebrew-skip"
# once we get this repo sync'd, we can rely on both tags being the same
cd ${SKIPPKGDIR}
git fetch --tags --force
#git tag -l --sort=-version:refname
SKIP_VERSION_OLD=$(git tag -l --sort=-version:refname | grep '[0-9]*\.[0-9]*\.[0-9]*' | head -n 1)
major=$(echo "${SKIP_VERSION_OLD}" | tr '.' '\n' | head -n 1 | tail -n 1)
minor=$(echo "${SKIP_VERSION_OLD}" | tr '.' '\n' | head -n 2 | tail -n 1)
patch=$(echo "${SKIP_VERSION_OLD}" | tr '.' '\n' | head -n 3 | tail -n 1)
case "${SEMVER_BUMP:-patch}" in
patch)
patch=$((patch+1))
;;
minor)
patch=0
minor=$((minor+1))
;;
major)
patch=0
minor=0
major=$((major+1))
;;
*)
echo "Invalid SEMVER_BUMP component: ${SEMVER_BUMP}"
return 2
esac
if [[ "${DRY_RUN:-'0'}" == "1" ]]; then
export SKIP_VERSION="${SKIP_VERSION_OLD}"
echo "Dry run: not bumping Skip version from: ${SKIP_VERSION}"
else
export SKIP_VERSION="${major}.${minor}.${patch}"
echo "Creating release and tagging new skip version: ${SKIP_VERSION_OLD} -> ${SKIP_VERSION}"
fi
# also sync the plugin version in skip/Sources/SkipDrive/Version.swift
git pull || true
SKIPDRIVE_VERSION_PATH="Sources/SkipDrive/Version.swift"
sed -I '' 's;public let skipVersion = .*;public let skipVersion = "'${SKIP_VERSION}'";g' "${SKIPDRIVE_VERSION_PATH}"
cd '-'
# mark the internal version in skipstone/Sources/SkipSyntax/Version.swift
SKIPSTONE_VERSION_PATH="Sources/SkipSyntax/Version.swift"
sed -I '' 's;public let skipVersion = .*;public let skipVersion = "'${SKIP_VERSION}'";g' "${SKIPSTONE_VERSION_PATH}"
# make sure checkup passes
# TODO: need a way to have `skip` forked from checkup use the local build
#swift run SkipRunner checkup
# make sure both private skipstone/ and public skip/ tests pass
#swift test --configuration debug --parallel
# note that these sometimes need to be disabled when a framework upate
# is dependent on a skipstone change; the swift test init tests will
# fail until there is a new release
#SKIPLOCAL=${PWD} swift test --configuration debug --package-path ../skip/
ARTIFACT_MACOS_BUILD_DIR=.build/artifactbundle-macos
$(dirname $(realpath $0))/build_macos_plugin.sh
cp -av ${SKIPSTONEDIR}/${ARTIFACT_MACOS_BUILD_DIR}/${PLUGIN_MACOS_ZIP} ${RELSTAGING}
PLUGIN_MACOS_CHECKSUM=$(shasum -a 256 ${RELSTAGING}/${PLUGIN_MACOS_ZIP} | cut -f 1 -d ' ')
ARTIFACT_LINUX_BUILD_DIR=.build/artifactbundle-linux
$(dirname $(realpath $0))/build_linux_plugin.sh
cp -av ${SKIPSTONEDIR}/${ARTIFACT_LINUX_BUILD_DIR}/${PLUGIN_LINUX_ZIP} ${RELSTAGING}
PLUGIN_LINUX_CHECKSUM=$(shasum -a 256 ${RELSTAGING}/${PLUGIN_LINUX_ZIP} | cut -f 1 -d ' ')
# make a release of the skip command
cd ${SKIPPKGDIR}
ARTIFACT_MACOS_URL="https://source.skip.tools/skip/releases/download/${SKIP_VERSION}/${PLUGIN_MACOS_ZIP}"
sed -I '' 's;.binaryTarget(name: "'${ARTIFACT}'", url:.*'${PLUGIN_MACOS_ZIP}'.*);.binaryTarget(name: "'${ARTIFACT}'", url: "'${ARTIFACT_MACOS_URL}'", checksum: "'${PLUGIN_MACOS_CHECKSUM}'");g' ${SKIPPKG}
ARTIFACT_LINUX_URL="https://source.skip.tools/skip/releases/download/${SKIP_VERSION}/${PLUGIN_LINUX_ZIP}"
sed -I '' 's;.binaryTarget(name: "'${ARTIFACT}'", url:.*'${PLUGIN_LINUX_ZIP}'.*);.binaryTarget(name: "'${ARTIFACT}'", url: "'${ARTIFACT_LINUX_URL}'", checksum: "'${PLUGIN_LINUX_CHECKSUM}'");g' ${SKIPPKG}
# package(url: "https://source.skip.tools/skipstone.git", exact: "1.6.12")
sed -I '' 's;.package(url: "https://.*/skipstone.git", exact: ".*");.package(url: "https://source.skip.tools/skipstone.git", exact: "'${SKIP_VERSION}'");g' ${SKIPPKG}
sed -I '' 's;.package(url: "https://.*/skip.git", from: ".*");.package(url: "https://source.skip.tools/skip.git", from: "'${SKIP_VERSION}'");g' "README.md"
if [[ "${DRY_RUN:-'0'}" == "1" ]]; then
echo "DRY RUN: EXITING"
exit 0
fi
git add Package.swift ${README_PATH} ${SKIPDRIVE_VERSION_PATH}
git add .
git commit --allow-empty --allow-empty-message -m "Release ${SKIP_VERSION}"
git tag "${SKIP_VERSION}" -m "Release ${SKIP_VERSION}"
git push --follow-tags
cd ${RELSTAGING}
# need to wait a bit for the tag to show up
sleep 5
gh release -R github.com/skiptools/skip create --verify-tag --generate-notes "${SKIP_VERSION}" *.zip
cd '-'
echo "Waiting to download to become available…"
sleep 15
# sometimes need to wait briefly for the artifact to become available
curl --location --fail --retry 10 --retry-all-errors --retry-max-time 120 -o /dev/null "${ARTIFACT_MACOS_URL}"
# now jump *back* to the package and make sure we can run the command
#if [ "${SKIPPKG}" != "/dev/null" ]; then
#swift package --disable-sandbox --allow-writing-to-package-directory SkipRunner info
#fi
# jump back and make a corresponding release in skipstone
cd ${SKIPSTONEDIR}
git add "${SKIPSTONE_VERSION_PATH}"
git commit --allow-empty --allow-empty-message -m "Release ${SKIP_VERSION}"
git tag "${SKIP_VERSION}" -m "Release ${SKIP_VERSION}"
git push --follow-tags
# need to wait a bit for the tag to show up
sleep 5
gh release -R github.com/skiptools/skipstone create --verify-tag --generate-notes "${SKIP_VERSION}"
# update the homebrew cask with the updated skip command
cd ${SKIPBREWDIR}
git pull || true
sed -I '' "s;version \".*\";version \"${SKIP_VERSION}\";g" Casks/skip.rb
# Update SHA-256 checksums in the Cask for each platform
sed -I '' "s; arm:[[:space:]]*\"[A-Za-z0-9]\{64\}\"; arm: \"${PLUGIN_MACOS_CHECKSUM}\";g" Casks/skip.rb
sed -I '' "s; x86_64:[[:space:]]*\"[A-Za-z0-9]\{64\}\"; x86_64: \"${PLUGIN_MACOS_CHECKSUM}\";g" Casks/skip.rb
sed -I '' "s; arm64_linux:[[:space:]]*\"[A-Za-z0-9]\{64\}\"; arm64_linux: \"${PLUGIN_LINUX_CHECKSUM}\";g" Casks/skip.rb
sed -I '' "s; x86_64_linux:[[:space:]]*\"[A-Za-z0-9]\{64\}\"; x86_64_linux: \"${PLUGIN_LINUX_CHECKSUM}\";g" Casks/skip.rb
git add Casks/skip.rb
git commit -m "Release ${SKIP_VERSION}"
git tag "${SKIP_VERSION}" -m "Release ${SKIP_VERSION}"
git push --follow-tags
# check that mint can build/install and run the tool
# works, but is slow and we don't document it
# mint run skiptools/skip version
# check that homebrew can install/upgrade and run the tool
HOMEBREW_AUTO_UPDATE_SECS=0 brew upgrade skiptools/skip/skip || brew install skiptools/skip/skip
skip welcome