Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
0aacaea9
Commit
0aacaea9
authored
Mar 20, 2016
by
Matt Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #686 from wmark/for-mholt
Reflow all bash scripts
parents
9e0b1b42
74a5cb2f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
84 deletions
+109
-84
.gitattributes
.gitattributes
+3
-0
build.bash
build.bash
+29
-29
dist/automate.sh
dist/automate.sh
+77
-55
No files found.
.gitattributes
View file @
0aacaea9
*.bash text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=2
*.sh text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=2
# files for systemd
# files for systemd
*.path text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=2
*.path text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=2
*.service text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=2
*.service text eol=lf whitespace=blank-at-eol,space-before-tab,tab-in-indent,trailing-space,tabwidth=2
...
...
build.bash
View file @
0aacaea9
...
@@ -8,48 +8,48 @@
...
@@ -8,48 +8,48 @@
#
#
# Outputs compiled program in current directory.
# Outputs compiled program in current directory.
# Default file name is 'ecaddy'.
# Default file name is 'ecaddy'.
#
set
-e
output
=
"
$1
"
set
-euo
pipefail
if
[
-z
"
$output
"
]
;
then
output
=
"ecaddy"
:
${
output_filename
:
=
"
${
1
:-}
"
}
fi
:
${
output_filename
:
=
"ecaddy"
}
pkg
=
main
pkg
=
main
ldflags
=()
# Timestamp of build
# Timestamp of build
builddate_id
=
$pkg
.buildDate
name
=
"
${
pkg
}
.buildDate"
builddate
=
`
date
-u
`
value
=
$(
date
--utc
+
"%F %H:%M:%SZ"
)
ldflags+
=(
"-X"
"
\"
${
name
}
=
${
value
}
\"
"
)
# Current tag, if HEAD is on a tag
# Current tag, if HEAD is on a tag
tag_id
=
$pkg
.gitTag
name
=
"
${
pkg
}
.gitTag"
set
+e
set
+e
tag
=
`
git describe
--exact-match
HEAD 2> /dev/null
`
value
=
"
$(
git describe
--exact-match
HEAD 2>/dev/null
)
"
set
-e
set
-e
ldflags+
=(
"-X"
"
\"
${
name
}
=
${
value
}
\"
"
)
# Nearest tag on branch
# Nearest tag on branch
lasttag_id
=
$pkg
.gitNearestTag
name
=
"
${
pkg
}
.gitNearestTag"
lasttag
=
`
git describe
--abbrev
=
0
--tags
HEAD
`
value
=
"
$(
git describe
--abbrev
=
0
--tags
HEAD
)
"
ldflags+
=(
"-X"
"
\"
${
name
}
=
${
value
}
\"
"
)
# Commit SHA
# Commit SHA
commit_id
=
$pkg
.gitCommit
name
=
"
${
pkg
}
.gitCommit"
commit
=
`
git rev-parse
--short
HEAD
`
value
=
"
$(
git rev-parse
--short
HEAD
)
"
ldflags+
=(
"-X"
"
\"
${
name
}
=
${
value
}
\"
"
)
# Summary of uncommited changes
# Summary of uncommitted changes
shortstat_id
=
$pkg
.gitShortStat
name
=
"
${
pkg
}
.gitShortStat"
shortstat
=
`
git diff-index
--shortstat
HEAD
`
value
=
"
$(
git diff-index
--shortstat
HEAD
)
"
ldflags+
=(
"-X"
"
\"
${
name
}
=
${
value
}
\"
"
)
# List of modified files
# List of modified files
files_id
=
$pkg
.gitFilesModified
name
=
"
${
pkg
}
.gitFilesModified"
files
=
`
git diff-index
--name-only
HEAD
`
value
=
"
$(
git diff-index
--name-only
HEAD |
tr
"
\n
"
","
|
sed
-e
's:,$::'
)
"
ldflags+
=(
"-X"
"
\"
${
name
}
=
${
value
}
\"
"
)
go build
-ldflags
"
set
-x
-X
\"
$builddate_id
=
$builddate
\"
go build
\
-X
\"
$tag_id
=
$tag
\"
-ldflags
"
${
ldflags
[*]
}
"
\
-X
\"
$lasttag_id
=
$lasttag
\"
-o
"
${
output_filename
}
"
-X
\"
$commit_id
=
$commit
\"
-X
\"
$shortstat_id
=
$shortstat
\"
-X
\"
$files_id
=
$files
\"
"
-o
"
$output
"
dist/automate.sh
View file @
0aacaea9
#!/usr/bin/env bash
#!/usr/bin/env bash
set
-e
set
-o
pipefail
set
-euo
pipefail
shopt
-s
nullglob
# if no files match glob, assume empty list instead of string literal
# if no files match glob, assume empty list instead of string literal
shopt
-s
nullglob
## PACKAGE TO BUILD
:
${
build_package
:
=
"github.com/mholt/caddy"
}
Package
=
github.com/mholt/caddy
:
${
dist_dir
:
=
"
${
GOPATH
}
/src/
${
build_package
}
/dist"
}
:
${
build_dir
:
=
"
${
dist_dir
}
/builds"
}
## PATHS TO USE
:
${
target_dir
:
=
"
${
dist_dir
}
/release"
}
DistDir
=
$GOPATH
/src/
$Package
/dist
BuildDir
=
$DistDir
/builds
# Bundles a single binary, given as first parameter, into an archive.
ReleaseDir
=
$DistDir
/release
package
()
{
# Binary inside the zip file is simply the project name
binbase
=
"
$(
basename
"
${
build_package
}
"
)
"
## BEGIN
if
[[
"
${
1
}
"
==
*
.exe
]]
;
then
binbase+
=
".exe"
# Compile binaries
fi
mkdir
-p
$BuildDir
bin
=
"
${
build_dir
}
/
${
binbase
}
"
cd
$BuildDir
rm
-f
caddy
*
# Name .zip file same as binary, but strip .exe from end
gox
$Package
zipname
=
"
$(
basename
"
${
1
%.exe
}
"
)
"
case
"
$(
printf
"
${
zipname
}
"
|
cut
-d
'_'
-f
2 |
sed
-e
's:[a-z]*bsd:bsd:'
)
"
in
# Zip them up with release notes and stuff
linux|bsd
)
zipname+
=
".tar.gz"
;;
mkdir
-p
$ReleaseDir
*
)
zipname+
=
".zip"
;;
cd
$ReleaseDir
esac
rm
-f
caddy
*
for
f
in
$BuildDir
/
*
# Compress distributable depending on extension
do
case
"
${
zipname
##*.
}
"
in
# Name .zip file same as binary, but strip .exe from end
zip
)
zipname
=
$(
basename
${
f
%
".exe"
}
)
zip
-j
"
${
target_dir
}
/
${
zipname
}
"
\
if
[[
$f
==
*
"linux"
*
]]
||
[[
$f
==
*
"bsd"
*
]]
;
then
"
${
1
}
"
\
zipname
=
${
zipname
}
.tar.gz
"
${
dist_dir
}
"
/
{
CHANGES.txt,LICENSES.txt,README.txt
}
else
printf
"@
$(
basename
"
${
1
}
"
)
\n
@=
${
binbase
}
\n
"
\
zipname
=
${
zipname
}
.zip
| zipnote
-w
"
${
target_dir
}
/
${
zipname
}
"
fi
;;
gz
)
# Binary inside the zip file is simply the project name
tar
-caf
"
${
target_dir
}
/
${
zipname
}
"
\
binbase
=
$(
basename
$Package
)
--owner
=
0
--group
=
0
\
if
[[
$f
==
*
.exe
]]
;
then
--transform
=
"s#
$(
basename
"
${
1
}
"
)
#
${
binbase
}
#"
\
binbase
=
$binbase
.exe
-C
"
$(
dirname
"
${
1
}
"
)
"
"
$(
basename
"
${
1
}
"
)
"
\
fi
-C
"
${
dist_dir
}
"
CHANGES.txt LICENSES.txt README.txt
bin
=
$BuildDir
/
$binbase
;;
mv
$f
$bin
esac
}
# Compress distributable
if
[[
$zipname
==
*
.zip
]]
;
then
prepare_directories
()
{
zip
-j
$zipname
$bin
$DistDir
/CHANGES.txt
$DistDir
/LICENSES.txt
$DistDir
/README.txt
mkdir
-p
"
${
build_dir
}
"
else
rm
-f
"
${
build_dir
}
"
/caddy
*
tar
-cvzf
$zipname
-C
$BuildDir
$binbase
-C
$DistDir
CHANGES.txt LICENSES.txt README.txt
fi
mkdir
-p
"
${
target_dir
}
"
rm
-f
"
${
target_dir
}
"
/caddy
*
# Put binary filename back to original
}
mv
$bin
$f
done
compile_binaries
()
{
(
cd
"
${
build_dir
}
"
;
gox
"
${
build_package
}
"
)
}
if
[[
"
${
1
:-}
"
==
""
]]
;
then
prepare_directories
compile_binaries
case
"
${
OSTYPE
}
"
in
linux
*
)
find
"
${
build_dir
}
"
-type
f
-executable
-print0
\
| xargs
--null
--max-args
=
1
--max-procs
=
$(
nproc
--ignore
=
1
)
-I
'{}'
\
"
${
0
}
"
package
'{}'
;;
*
)
while
read
f
;
do
package
"
${
f
}
"
done
< <
(
ls
-1
"
${
build_dir
}
"
/caddy
*
)
;;
esac
else
${
1
}
"
${
2
}
"
fi
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