-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move commands to subdir 'lib/cmd'
This also comes with an update to the Glue scripts, which I couldn't really avoid
- Loading branch information
1 parent
a151090
commit 32a8aa0
Showing
23 changed files
with
206 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,60 +13,56 @@ main() { | |
ensure.file glue.toml | ||
ensure.file glue-auto.toml | ||
|
||
# TODO: use function | ||
mkdir -p .glue/generated/tool-makepkg | ||
toml.get_key project glue.toml | ||
local myProject="$REPLY" | ||
|
||
# TODO: get these values somewhere else | ||
toml.get_key name glue.toml | ||
local myPkg="$REPLY" | ||
local myName="Edwin Kofler" | ||
local myEmail="[email protected]" | ||
toml.get_key desc glue.toml | ||
local myDesc="$REPLY" | ||
|
||
toml.get_key name glue.toml | ||
local myName="$REPLY" | ||
|
||
toml.get_key email glue.toml | ||
local myEmail="$REPLY" | ||
|
||
toml.get_key version glue-auto.toml | ||
local myVer="$REPLY" | ||
myVer="${myVer/-/_}" | ||
local myVer="$REPLY"; myVer="${myVer/-/_}" | ||
|
||
ensure.nonZero 'myProject' "$myProject" | ||
ensure.nonZero 'myDesc' "$myDesc" | ||
ensure.nonZero 'myName' "$myName" | ||
ensure.nonZero 'myEmail' "$myEmail" | ||
ensure.nonZero 'myVer' "$myVer" | ||
# glue useConfig(tool-makepkg) | ||
util.get_config "tool-makepkg/dev/PKGBUILD" | ||
|
||
# glue useConfig(result-pacman-package) | ||
util.get_config "result-pacman-package/dev/PKGBUILD" | ||
pkgbuildFile="$REPLY" | ||
|
||
generated.in 'result-pacman-package' | ||
( | ||
mkdir -p .glue/generated/tool-makepkg/dev | ||
cd .glue/generated/tool-makepkg/dev || error.cd_failed | ||
cd "$GENERATED_DIR" || error.cd_failed | ||
mkdir dev | ||
cd dev || error.cd_failed | ||
|
||
cp "$pkgbuildFile" . | ||
tar --create --directory "$GLUE_WD" --file "$myProject-$myVer.tar.gz" --exclude './.git' \ | ||
--exclude "$myProject-$myVer.tar.gz" --transform "s/^\./$myProject-$myVer/" ./ | ||
|
||
# TODO: bash templating | ||
cp "$pkgbuildFile" . | ||
sed -i -e "s/# Maintainer:.*/# Maintainer: $myName <$myEmail>/g" PKGBUILD | ||
sed -i -e "s/pkgname=.*\$/pkgname='$myPkg'/g" PKGBUILD | ||
sed -i -e "s/pkgname=.*\$/pkgname='$myProject'/g" PKGBUILD | ||
sed -i -e "s/pkgver=.*\$/pkgver='$myVer'/g" PKGBUILD | ||
sed -i -e "s/pkgdesc=.*\$/pkgdesc='$myDesc'/g" PKGBUILD | ||
sed -i -e "s/url=.*\$/url='https:\/\/github.com\/eankeen\/$myPkg'/g" PKGBUILD | ||
sed -i -e "s/source=.*\$/source=\(\$pkgname-\$pkgver.tar.gz::http:\/\/localhost:9334\/v\$pkgver.tar.gz\)/g" PKGBUILD | ||
|
||
# TODO: assumption on working directory | ||
tar --create --directory "$GLUE_WD" --file "$myPkg-$myVer.tar.gz" ../"$myPkg" | ||
rm -rf "$myPkg-$myVer" | ||
# tar xf "$myPkg-$myVer.tar.gz" | ||
# mv "$myPkg" "$myPkg-$myVer" | ||
# rm -rf "$myPkg-$myVer/.git" | ||
|
||
local sum="$(sha256sum "$myPkg-$myVer.tar.gz")" | ||
sed -i -e "s/url=.*\$/url='https:\/\/github.com\/eankeen\/$myProject'/g" PKGBUILD | ||
sed -i -e "s/source=.*\$/source=\(\$pkgname-\$pkgver.tar.gz::\)/g" PKGBUILD | ||
local sum="$(sha256sum "$myProject-$myVer.tar.gz")" | ||
sum="${sum%% *}" | ||
sed -i -e "s/sha256sums=.*\$/sha256sums=\('$sum'\)/g" PKGBUILD | ||
|
||
namcap PKGBUILD | ||
makepkg -Cfsrc | ||
namcap ./*.zst | ||
) || exit | ||
generated.out | ||
|
||
# TODO: think about more fine grained linting control in the whole SDLC | ||
# namcap PKGBUILD | ||
# namcap ./*.zst | ||
|
||
} | ||
|
||
main "$@" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
eval "$GLUE_BOOTSTRAP" | ||
bootstrap || exit | ||
|
||
unset main | ||
main() { | ||
local newVersion="$1" | ||
ensure.nonZero 'newVersion' "$newVersion" | ||
|
||
# TODO: show which files changed | ||
find . -ignore_readdir_race -regex '\./pkg/.*\.\(sh\|bash\)' -print0 2>/dev/null \ | ||
| xargs -r0 \ | ||
sed -i -e "s|\(PROGRAM_VERSION=\"\).*\(\"\)|\1$newVersion\2|g" | ||
log.info "util-Bash-version-bump: Bump done" | ||
} | ||
|
||
main "$@" | ||
unset main | ||
|
||
unbootstrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,70 @@ | ||
#!/usr/bin/env bash | ||
# eval "$GLUE_BOOTSTRAP" | ||
# bootstrap || exit | ||
eval "$GLUE_BOOTSTRAP" | ||
bootstrap || exit | ||
|
||
# @file util-release-post.sh | ||
# @brief Steps to perform after specialized version bumping | ||
# - Ensure a dirty Git working tree | ||
# - Add bumped files to commit with version number | ||
# - Make GitHub release | ||
|
||
unset main | ||
main() { | ||
local -r dryStatus="$1" | ||
local newVersion="$2" | ||
|
||
ensure.nonZero 'newVersion' "$newVersion" | ||
|
||
ensure.cmd 'git' | ||
ensure.cmd 'gh' | ||
|
||
ensure.nonZero 'newVersion' "$newVersion" | ||
|
||
isDry() { | ||
# must be set to 'notDry' to not be dry. | ||
# Defaults to 'not dry' | ||
[ "$dryStatus" != "notDry" ] | ||
} | ||
|
||
if isDry; then | ||
log.info "Running release process in dry mode" | ||
fi | ||
|
||
# Ensure working tree is dirty | ||
if [ -z "$(git status --porcelain)" ]; then | ||
die 'Working tree is not dirty. Cannot make a release if versions have not been bumped in their respective files' | ||
if isDry; then | ||
local cmd="log.warn" | ||
else | ||
local cmd="die" | ||
fi | ||
|
||
"$cmd" 'Working tree is not dirty. Cannot make a release if versions have not been bumped in their respective files' | ||
fi | ||
|
||
# Local Release | ||
git add -A | ||
git commit -m "chore(release): v$newVersion" | ||
git tag -a "v$newVersion" -m "Release $newVersion" HEAD | ||
git push --follow-tags origin HEAD | ||
|
||
local -a args=() | ||
if [ -f CHANGELOG.md ]; then | ||
args+=("-F" "CHANGELOG.md") | ||
elif [ -f changelog.md ]; then | ||
args+=("-F" "changelog.md") | ||
if isDry; then | ||
log.info "Skipping Git taging and artifact release" | ||
else | ||
# '-F' is required for non-interactivity | ||
args+=("-F" "") | ||
log.warn 'CHANGELOG.md file not found. Creating empty notes file for release' | ||
fi | ||
git add -A | ||
git commit -m "chore(release): v$newVersion" | ||
git tag -a "v$newVersion" -m "Release $newVersion" HEAD | ||
git push --follow-tags origin HEAD | ||
|
||
# Remote Release | ||
gh release create "v$newVersion" --target main --title "v$newVersion" "${args[@]}" | ||
local -a args=() | ||
if [ -f CHANGELOG.md ]; then | ||
args+=("-F" "CHANGELOG.md") | ||
elif [ -f changelog.md ]; then | ||
args+=("-F" "changelog.md") | ||
else | ||
# '-F' is required for non-interactivity | ||
args+=("-F" "") | ||
log.warn 'CHANGELOG.md file not found. Creating empty notes file for release' | ||
fi | ||
|
||
# Remote Release | ||
gh release create "v$newVersion" --target main --title "v$newVersion" "${args[@]}" | ||
fi | ||
} | ||
|
||
main "$@" | ||
unset main | ||
|
||
# unbootstrap | ||
unbootstrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.