-
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.
- Loading branch information
1 parent
b45651e
commit 374791b
Showing
6 changed files
with
231 additions
and
54 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
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,19 +1,25 @@ | ||
BIN_NAME = timetrack.desktop | ||
|
||
macos: | ||
npm run make -- --arch=x64 --platform=darwin | ||
PLATFORM=macos ./scripts/build.sh | ||
|
||
linux: | ||
npm run make -- --arch=x64 --platform=linux | ||
PLATFORM=linux ./scripts/build.sh | ||
|
||
windows: | ||
npm run make -- --arch=x64 --platform=win32 | ||
PLATFORM=windows ./scripts/build.sh | ||
|
||
archives: | ||
cd out/ && tar -czvf $(BIN_NAME)_$(VERSION)_linux-x64.tar.gz $(BIN_NAME)-linux-x64 | ||
CREATE_ARCHIVES=1 PLATFORM=linux ./scripts/release.sh | ||
|
||
linux-release: | ||
REPLACE=1 PLATFORM=linux ./scripts/release.sh | ||
|
||
windows-release: | ||
REPLACE=1 PLATFORM=windows ./scripts/release.sh | ||
|
||
default-release: | ||
gh release create --generate-notes v$(VERSION) out/make/deb/x64/$(BIN_NAME)_$(VERSION)_amd64.deb out/make/rpm/x64/$(BIN_NAME)-$(VERSION)-1.x86_64.rpm "out/make/squirrel.windows/x64/timetrack.desktop-$(VERSION) Setup.exe" out/make/squirrel.windows/x64/timetrack.desktop-$(VERSION)-full.nupkg | ||
macos-release: | ||
tree out/ | ||
# gh release edit v$(VERSION) | ||
REPLACE=1 PLATFORM=macos ./scripts/release.sh | ||
|
||
run: | ||
npm run start |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$VERSION" ]; then echo "Error: VERSION is not set"; exit 1; fi | ||
if [ -z "$PLATFORM" ]; then echo "Error: PLATFORM is not set"; exit 1; fi | ||
|
||
BUILDOS="" | ||
|
||
update_package_json_version() { | ||
local tmp | ||
tmp=$(mktemp) | ||
jq --arg v "$VERSION" '.version = $v' package.json > "$tmp" && mv "$tmp" package.json | ||
} | ||
|
||
set_buildos_based_on_platform() { | ||
case $PLATFORM in | ||
linux) | ||
BUILDOS="linux" | ||
;; | ||
windows) | ||
BUILDOS="win32" | ||
;; | ||
macos) | ||
BUILDOS="darwin" | ||
;; | ||
*) | ||
echo "Error: PLATFORM $PLATFORM is not supported" | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
set_buildos_based_on_platform | ||
update_package_json_version | ||
|
||
npm run make -- --arch=x64 --platform=$BUILDOS |
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,114 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$VERSION" ]; then echo "Error: VERSION is not set"; exit 1; fi | ||
if [ -z "$PLATFORM" ]; then echo "Error: PLATFORM is not set"; exit 1; fi | ||
|
||
BIN_NAME="timetrack.desktop" | ||
RELEASE_ACTION="create" | ||
GH_TAG="v$VERSION" | ||
FILES=() | ||
|
||
LINUX_FILES=( | ||
"out/make/deb/x64/${BIN_NAME}_${VERSION}_amd64.deb" | ||
"out/make/rpm/x64/${BIN_NAME}-${VERSION}-1.x86_64.rpm" | ||
) | ||
|
||
WINDOWS_FILES=( | ||
"out/make/squirrel.windows/x64/${BIN_NAME}-${VERSION} Setup.exe" | ||
"out/make/squirrel.windows/x64/${BIN_NAME}-${VERSION}-full.nupkg" | ||
) | ||
|
||
MACOS_FILES=( | ||
"out/make/$BIN_NAME-$VERSION-x64.dmg" | ||
) | ||
|
||
|
||
set_release_action() { | ||
if gh release view "$GH_TAG" --json id --jq .id > /dev/null 2>&1; then | ||
echo "Release $GH_TAG already exists, updating it" | ||
RELEASE_ACTION="edit" | ||
else | ||
echo "Release $GH_TAG does not exist, creating it" | ||
RELEASE_ACTION="create" | ||
fi | ||
} | ||
|
||
check_files_exist() { | ||
files=() | ||
for file in "${FILES[@]}"; do | ||
if [ ! -f "$file" ]; then | ||
files+=("$file") | ||
fi | ||
done | ||
if [ ${#files[@]} -gt 0 ]; then | ||
echo "Error: the following files do not exist:" | ||
for file in "${files[@]}"; do | ||
printf " - %s\n" "$file" | ||
done | ||
exit 1 | ||
fi | ||
} | ||
|
||
set_files_based_on_platform() { | ||
case $PLATFORM in | ||
linux) | ||
FILES=("${LINUX_FILES[@]}") | ||
;; | ||
windows) | ||
FILES=("${WINDOWS_FILES[@]}") | ||
;; | ||
macos) | ||
FILES=("${MACOS_FILES[@]}") | ||
;; | ||
*) | ||
echo "Error: PLATFORM $PLATFORM is not supported" | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
print_files() { | ||
echo "Files to upload:" | ||
for file in "${FILES[@]}"; do | ||
printf " - %s\n" "$file" | ||
done | ||
} | ||
|
||
do_gh_release() { | ||
if [ "$RELEASE_ACTION" == "edit" ]; then | ||
if [ -z "$REPLACE" ]; then | ||
echo "Trying to upload files to existing release $GH_TAG" | ||
print_files | ||
gh release upload "$GH_TAG" "${FILES[@]}" | ||
else | ||
echo "Overwriting existing release $GH_TAG" | ||
print_files | ||
gh release upload --clobber "$GH_TAG" "${FILES[@]}" | ||
fi | ||
else | ||
echo "Creating new release $GH_TAG" | ||
print_files | ||
gh release create --generate-notes "$GH_TAG" "${FILES[@]}" | ||
fi | ||
} | ||
|
||
create_archives() { | ||
cd out/ && tar -czvf "${BIN_NAME}_${VERSION}_linux-x64.tar.gz" "${BIN_NAME}-linux-x64" | ||
} | ||
|
||
release() { | ||
set_release_action | ||
set_files_based_on_platform | ||
check_files_exist | ||
do_gh_release | ||
} | ||
|
||
boot() { | ||
if [ -z "$CREATE_ARCHIVES" ]; then | ||
release | ||
else | ||
create_archives | ||
fi | ||
} | ||
|
||
boot |