Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
7c87c1ff
Unverified
Commit
7c87c1ff
authored
Mar 13, 2024
by
Lincoln Nogueira
Committed by
GitHub
Mar 13, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update build scripts (#3085)
parent
963c6304
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
62 deletions
+36
-62
build.ps1
scripts/build.ps1
+18
-32
build.sh
scripts/build.sh
+18
-30
No files found.
scripts/build.ps1
View file @
7c87c1ff
...
@@ -43,6 +43,7 @@ if ([string]::IsNullOrWhiteSpace($repoRoot)) {
...
@@ -43,6 +43,7 @@ if ([string]::IsNullOrWhiteSpace($repoRoot)) {
Write-Host
"Repository root: "
-NoNewline
Write-Host
"Repository root: "
-NoNewline
Write-Host
$repoRoot
-f Blue
Write-Host
$repoRoot
-f Blue
Push-Location
Set-Location
"
$repoRoot
/web"
Set-Location
"
$repoRoot
/web"
if
(
-not
(
Get-Command pnpm -ErrorAction SilentlyContinue
))
{
if
(
-not
(
Get-Command pnpm -ErrorAction SilentlyContinue
))
{
...
@@ -50,6 +51,7 @@ if (-not (Get-Command pnpm -ErrorAction SilentlyContinue)) {
...
@@ -50,6 +51,7 @@ if (-not (Get-Command pnpm -ErrorAction SilentlyContinue)) {
npm
install
-g pnpm
npm
install
-g pnpm
if
(!
$?
)
{
if
(!
$?
)
{
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not install pnpm. See above."
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not install pnpm. See above."
Pop-Location
Exit
1
Exit
1
}
}
}
}
...
@@ -58,39 +60,37 @@ Write-Host "`nInstalling frontend dependencies..." -f DarkYellow
...
@@ -58,39 +60,37 @@ Write-Host "`nInstalling frontend dependencies..." -f DarkYellow
pnpm i --frozen-lockfile
pnpm i --frozen-lockfile
if
(!
$?
)
{
if
(!
$?
)
{
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not install frontend dependencies. See above."
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not install frontend dependencies. See above."
Pop-Location
Exit
1
Exit
1
}
}
Write-Host
"Frontend dependencies installed!"
-f green
Write-Host
"Frontend dependencies installed!"
-f green
Write-Host
"
`n
Removing previous frontend build from ./build/dist ..."
-f Magenta
Remove-Item
"
$repoRoot
/build/dist"
-Recurse -Force -ErrorAction SilentlyContinue
if
(!
$?
)
{
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not remove frontend from ./build/dist. See above."
Pop-Location
Exit
1
}
Write-Host
"
`n
Building frontend..."
-f DarkYellow
Write-Host
"
`n
Building frontend..."
-f DarkYellow
$frontendTime
=
Measure-Command
{
$frontendTime
=
Measure-Command
{
&pnpm build | Out-Host
&pnpm build | Out-Host
}
}
if
(!
$?
)
{
if
(!
$?
)
{
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not build frontend. See above."
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not build frontend. See above."
Pop-Location
Exit
1
Exit
1
}
else
{
Write-Host
"Frontend built!"
-f green
}
}
else
{
if
(!
$?
)
{
Write-Host
"Frontend built!"
-f green
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not generate buf types. See above."
Exit
1
}
else
{
Write-Host
"buf types generated!"
-f green
}
Write-Host
"
`n
Backing up frontend placeholder..."
-f Magenta
Move-Item
"
$repoRoot
/server/frontend/dist"
"
$repoRoot
/server/frontend/dist.bak"
-Force -ErrorAction Stop
if
(!
$?
)
{
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not backup frontend placeholder. See above."
Exit
1
}
}
Write-Host
"Moving frontend build to ./
server/fronten
d/dist..."
-f Magenta
Write-Host
"Moving frontend build to ./
buil
d/dist..."
-f Magenta
Move-Item
"
$repoRoot
/web/dist"
"
$repoRoot
/
server
/"
-Force -ErrorAction Stop
Move-Item
"
$repoRoot
/web/dist"
"
$repoRoot
/
build
/"
-Force -ErrorAction Stop
if
(!
$?
)
{
if
(!
$?
)
{
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not move frontend build to /server/frontend/dist. See above."
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not move frontend build to ./build/dist. See above."
Pop-Location
Exit
1
Exit
1
}
}
...
@@ -122,20 +122,6 @@ Write-Host "Backend built!" -f green
...
@@ -122,20 +122,6 @@ Write-Host "Backend built!" -f green
Write-Host
"
`n
Frontend build took
$(
$frontendTime
.TotalSeconds
)
seconds."
-f Cyan
Write-Host
"
`n
Frontend build took
$(
$frontendTime
.TotalSeconds
)
seconds."
-f Cyan
Write-Host
"Backend builds took
$(
$backendTime
.TotalSeconds
)
seconds."
-f Cyan
Write-Host
"Backend builds took
$(
$backendTime
.TotalSeconds
)
seconds."
-f Cyan
Write-Host
"
`n
Removing frontend from ./server/frontend/dist ..."
-f Magenta
Remove-Item
"
$repoRoot
/server/frontend/dist"
-Recurse -Force -ErrorAction SilentlyContinue
if
(!
$?
)
{
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not remove frontend from /server/frontend/dist. See above."
Exit
1
}
Write-Host
"Restoring frontend placeholder..."
-f Magenta
Move-Item
"
$repoRoot
/server/frontend/dist.bak"
"
$repoRoot
/server/frontend/dist"
-Force -ErrorAction Stop
if
(!
$?
)
{
Write-Host
-BackgroundColor red -ForegroundColor white
"Could not restore frontend placeholder. See above."
Exit
1
}
Write-Host
"
`n
Builds:"
-f White
Write-Host
"
`n
Builds:"
-f White
foreach
(
$build
in
$goBuilds
)
{
foreach
(
$build
in
$goBuilds
)
{
$output
=
[
IO.Path]::Combine
(
$repoRoot
,
"build"
,
"memos-
$os
-
$arch
"
)
$output
=
[
IO.Path]::Combine
(
$repoRoot
,
"build"
,
"memos-
$os
-
$arch
"
)
...
...
scripts/build.sh
View file @
7c87c1ff
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
# * node.js
# * node.js
# * npm
# * npm
# Usage:
# Usage:
# chmod +x ./scripts/build.sh
# chmod +x ./scripts/build.sh
# ./scripts/build.sh
# ./scripts/build.sh
#
#
...
@@ -53,15 +53,15 @@ else
...
@@ -53,15 +53,15 @@ else
echo
-e
"Repository root:
\0
33[0;34m
$repo_root
\0
33[0m"
echo
-e
"Repository root:
\0
33[0;34m
$repo_root
\0
33[0m"
fi
fi
pushd
$repo_root
cd
"
$repo_root
/web"
cd
"
$repo_root
/web"
if
!
command
-v
pnpm &> /dev/null
if
!
command
-v
pnpm &>/dev/null
;
then
then
echo
-e
"
\n\0
33[35mInstalling pnpm...
\0
33[0m"
echo
-e
"
\n\0
33[35mInstalling pnpm...
\0
33[0m"
npm
install
-g
pnpm
npm
install
-g
pnpm
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
-e
"
\0
33[0;31mFailed to install pnpm! Exiting.
\0
33[0m"
echo
-e
"
\0
33[0;31mFailed to install pnpm! Exiting.
\0
33[0m"
popd
exit
1
exit
1
fi
fi
fi
fi
...
@@ -70,31 +70,35 @@ echo -e "\n\033[33mInstalling frontend dependencies...\033[0m"
...
@@ -70,31 +70,35 @@ echo -e "\n\033[33mInstalling frontend dependencies...\033[0m"
pnpm i
--frozen-lockfile
pnpm i
--frozen-lockfile
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
-e
"
\0
33[0;31mFrontend dependencies failed to install! Exiting.
\0
33[0m"
echo
-e
"
\0
33[0;31mFrontend dependencies failed to install! Exiting.
\0
33[0m"
popd
exit
1
exit
1
fi
fi
echo
-e
"
\0
33[32mFrontend dependencies installed!
\0
33[0m"
echo
-e
"
\0
33[32mFrontend dependencies installed!
\0
33[0m"
echo
-e
"
\n\0
33[35mRemoving previous frontend build from ./build/dist...
\0
33[0m"
rm
-rf
$repo_root
/build/dist
if
[
$?
-ne
0
]
;
then
echo
-e
"
\0
33[93mCould not remove frontend from ./build/dist.
\0
33[0m"
popd
exit
1
fi
echo
-e
"
\n\0
33[33mBuilding frontend...
\0
33[0m"
echo
-e
"
\n\0
33[33mBuilding frontend...
\0
33[0m"
pnpm build
pnpm build
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
-e
"
\0
33[0;31mFrontend build failed! Exiting.
\0
33[0m"
echo
-e
"
\0
33[0;31mFrontend build failed! Exiting.
\0
33[0m"
popd
exit
1
exit
1
fi
fi
echo
-e
"
\0
33[32mFrontend built!
\0
33[0m"
echo
-e
"
\0
33[32mFrontend built!
\0
33[0m"
cd
$repo_root
cd
$repo_root
echo
-e
"
\n\0
33[35mBacking up frontend placeholder...
\0
33[0m"
echo
-e
"
\0
33[35mMoving frontend build to ./build/dist...
\0
33[0m"
mv
-f
"
$repo_root
/server/frontend/dist"
"
$repo_root
/server/frontend/dist.bak"
mv
-f
"
$repo_root
/web/dist"
"
$repo_root
/build/"
if
[
$?
-ne
0
]
;
then
echo
-e
"
\0
33[0;31mFailed to backup frontend placeholder! Exiting.
\0
33[0m"
exit
1
fi
echo
-e
"
\0
33[35mMoving frontend build to ./server/frontend/dist...
\0
33[0m"
mv
-f
"
$repo_root
/web/dist"
"
$repo_root
/server/"
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
echo
-e
"
\0
33[0;31mFailed to move frontend build! Exiting.
\0
33[0m"
echo
-e
"
\0
33[0;31mFailed to move frontend build! Exiting.
\0
33[0m"
popd
exit
1
exit
1
fi
fi
...
@@ -109,7 +113,7 @@ for build in "${goBuilds[@]}"; do
...
@@ -109,7 +113,7 @@ for build in "${goBuilds[@]}"; do
if
[
"
$os
"
=
"windows"
]
;
then
if
[
"
$os
"
=
"windows"
]
;
then
output
=
"
$output
.exe"
output
=
"
$output
.exe"
fi
fi
CGO_ENABLED
=
0
GOOS
=
$os
GOARCH
=
$arch
go build
-trimpath
-ldflags
=
"
${
ldFlags
[*]
}
"
-o
"
$output
"
./bin/memos/main.go
CGO_ENABLED
=
0
GOOS
=
$os
GOARCH
=
$arch
go build
-trimpath
-ldflags
=
"
${
ldFlags
[*]
}
"
-o
"
$output
"
./bin/memos/main.go
echo
-e
"
\0
33[34mBuilding
$os
/
$arch
to
$output
...
\0
33[0m"
echo
-e
"
\0
33[34mBuilding
$os
/
$arch
to
$output
...
\0
33[0m"
...
@@ -121,22 +125,6 @@ done
...
@@ -121,22 +125,6 @@ done
echo
-e
"
\0
33[32mBackend built!
\0
33[0m"
echo
-e
"
\0
33[32mBackend built!
\0
33[0m"
echo
-e
"
\n\0
33[35mRemoving frontend from ./server/frontend/dist...
\0
33[0m"
rm
-rf
$repo_root
/server/frontend/dist
if
[
$?
-ne
0
]
then
echo
-e
"
\0
33[93mCould not remove frontend from /server/frontend/dist.
\0
33[0m"
exit
1
fi
echo
-e
"
\0
33[35mRestoring frontend placeholder...
\0
33[0m"
mv
$repo_root
/server/frontend/dist.bak
$repo_root
/server/frontend/dist
if
[
$?
-ne
0
]
then
echo
-e
"
\0
33[93mCould not restore frontend placeholder.
\0
33e[0m"
exit
1
fi
echo
-e
"
\n\0
33[37mBuilds:
\0
33[0m"
echo
-e
"
\n\0
33[37mBuilds:
\0
33[0m"
for
build
in
"
${
goBuilds
[@]
}
"
;
do
for
build
in
"
${
goBuilds
[@]
}
"
;
do
os
=
$(
echo
$build
|
cut
-d
'/'
-f1
)
os
=
$(
echo
$build
|
cut
-d
'/'
-f1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment