| 
									
										
										
										
											2017-12-25 15:01:33 -05:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [[ $# -eq 0 ]] ; then | 
					
						
							|  |  |  |     echo "Missing argument of new version" | 
					
						
							|  |  |  |     exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | VERSION=$1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ! [[ ${VERSION} =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(-.+)?$ ]] ; | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |     echo "Version ${VERSION} isn't in format X.Y.Z" | 
					
						
							|  |  |  |     exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ! git diff-index --quiet HEAD --; then | 
					
						
							|  |  |  |     echo "There are uncommitted changes" | 
					
						
							|  |  |  |     exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 21:05:08 -05:00
										 |  |  | echo "Releasing Trilium $VERSION" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 20:45:59 -05:00
										 |  |  | jq '.version = "'$VERSION'"' package.json|sponge package.json | 
					
						
							| 
									
										
										
										
											2017-12-25 15:01:33 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 21:05:08 -05:00
										 |  |  | echo 'module.exports = { build_date:"'`date --iso-8601=seconds`'", build_revision: "'`git log -1 --format="%H"`'" };' > services/build.js | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 15:01:33 -05:00
										 |  |  | TAG=v$VERSION | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 21:05:08 -05:00
										 |  |  | echo "Committing package.json version change" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | git commit -m "release $VERSION" | 
					
						
							| 
									
										
										
										
											2017-12-25 15:01:33 -05:00
										 |  |  | git push | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 21:05:08 -05:00
										 |  |  | echo "Tagging commit with $TAG" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 15:01:33 -05:00
										 |  |  | git tag $TAG | 
					
						
							|  |  |  | git push origin $TAG | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 21:05:08 -05:00
										 |  |  | bin/build.sh | 
					
						
							| 
									
										
										
										
											2017-12-25 15:01:33 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 21:05:08 -05:00
										 |  |  | bin/package.sh | 
					
						
							| 
									
										
										
										
											2017-12-25 15:01:33 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | LINUX_BUILD=trilium-linux-$VERSION.7z | 
					
						
							|  |  |  | WINDOWS_BUILD=trilium-windows-$VERSION.7z | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 21:05:08 -05:00
										 |  |  | echo "Creating release in GitHub" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 15:01:33 -05:00
										 |  |  | github-release release \
 | 
					
						
							|  |  |  |     --tag $TAG \
 | 
					
						
							|  |  |  |     --name "$TAG release" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 21:05:08 -05:00
										 |  |  | echo "Uploading linux build" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 15:01:33 -05:00
										 |  |  | github-release upload \
 | 
					
						
							|  |  |  |     --tag $TAG \
 | 
					
						
							|  |  |  |     --name "$LINUX_BUILD" \
 | 
					
						
							|  |  |  |     --file "dist/$LINUX_BUILD" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 21:05:08 -05:00
										 |  |  | echo "Uploading windows build" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 15:01:33 -05:00
										 |  |  | github-release upload \
 | 
					
						
							|  |  |  |     --tag $TAG \
 | 
					
						
							|  |  |  |     --name "$WINDOWS_BUILD" \
 | 
					
						
							| 
									
										
										
										
											2017-12-25 21:05:08 -05:00
										 |  |  |     --file "dist/$WINDOWS_BUILD" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo "Release finished!" |