Skip to content

Commit

Permalink
extras: add release.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Oct 25, 2024
1 parent a1f26a6 commit 87f00fc
Showing 1 changed file with 148 additions and 0 deletions.
148 changes: 148 additions & 0 deletions extras/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#!/usr/bin/env bash

version="$1"

[ "${version}" ] || {
echo "Usage: $0 <version>"
exit 1
}

linux_folder=tl-${version}-linux-x86_64
linux_pkg=${linux_folder}.tar.gz
windows_folder=tl-${version}-windows-x86_64
windows_pkg=${windows_folder}.zip

grep -q "# ${version}$" CHANGELOG.md || {
echo "Please update the CHANGELOG.md for the release."
exit 1
}

git status --porcelain CHANGELOG.md | grep -q "^ M" && {
git add CHANGELOG.md
git commit -m "Prepare changelog for Teal $version"
}

git status --porcelain --untracked-files=no | grep "." && {
echo "You have uncommitted changes, please commit or stash first."
exit 1
}

git stash

git checkout .

sed -i 's/^local VERSION = .*/local VERSION = "'${version}'"/' tl.tl
sed -i 's/^local VERSION = .*/local VERSION = "'${version}'"/' tl.lua

git status --porcelain tl.tl | grep -q " M " || {
echo "Failed to update the version number in tl.tl."
exit 1
}

git status --porcelain tl.lua | grep -q " M " || {
echo "Failed to update the version number in tl.lua."
exit 1
}

git commit tl.tl tl.lua -m "Release ${version}" || {
echo "Failed to create the release commit."
exit 1
}

git push || {
echo "Failed to push the release commit."

# Undo release commit
git reset HEAD^ &> /dev/null
git checkout . &> /dev/null
exit 1
}

git tag v${version}

git push origin v${version} || {
echo "Failed to push the release tag."
exit 1
}

[ $(ls tl-dev-*.rockspec | wc -l) = 1 ] || {
echo "Multiple dev rockspecs fonud."
exit 1
}

luarocks new_version tl-dev-*.rockspec "${version}" --tag="v${version}" || {
echo "Failed to create the new rockspec."
exit 1
}

./luarocks upload tl-${version}-1.rockspec || {
echo "Failed to upload the new rockspec."
exit 1
}

sed -i 's/^local VERSION = .*/local VERSION = "'${version}'+dev"/' tl.tl
sed -i 's/^local VERSION = .*/local VERSION = "'${version}'+dev"/' tl.lua

git status --porcelain tl.tl | grep -q " M " || {
echo "Failed to update the version number in tl.tl."
exit 1
}

git status --porcelain tl.lua | grep -q " M " || {
echo "Failed to update the version number in tl.lua."
exit 1
}

git commit tl.tl tl.lua -m "Update version_string"

git push || {
echo "Failed to push the post-release commit."
exit 1
}

cat <<EOF > _binary/tlconfig.lua
return {
source_dir = "src",
build_dir = "build",
}
EOF

extras/binary.sh

rm -rf $linux_folder
mkdir $linux_folder
cp README.md CHANGELOG.md LICENSE _binary/tlconfig.lua $linux_folder
cp -a docs/ $linux_folder
mkdir $linux_folder/src
cp tl.tl $linux_folder/src
mkdir $linux_folder/build
cp tl.lua $linux_folder/build
cp _binary/build/tl $linux_folder
tar czvpf $linux_pkg $linux_folder

extras/binary.sh --windows

rm -rf $windows_folder
mkdir $windows_folder
cp README.md CHANGELOG.md LICENSE _binary/tlconfig.lua $windows_folder
cp -a docs/ $windows_folder
mkdir $windows_folder/src
cp tl.tl $windows_folder/src
mkdir $windows_folder/build
cp tl.lua $windows_folder/build
cp _binary/build/tl.exe $windows_folder
zip -r $windows_pkg $windows_folder

vtag=${version//./}

cat <<EOF > _binary/release.txt
Teal $version
* [What's New in Teal $version](https://github.com/teal-language/tl/blob/v$version/CHANGELOG.md#$vtag)
EOF

hub release create -F _binary/release.txt -a $linux_pkg -a $windows_pkg v$version

echo "*** tl ${version} is now released! ***"
exit 0

0 comments on commit 87f00fc

Please sign in to comment.