Skip to content

Commit

Permalink
update goreleaser builds
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana committed Nov 26, 2023
1 parent 14e7259 commit 1740901
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
10 changes: 7 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ project_name: s3www

before:
hooks:
- go mod tidy -compat=1.17
- go mod tidy -compat=1.21

builds:
-
flags:
- -trimpath
goos:
- darwin
- linux
Expand All @@ -34,6 +33,11 @@ builds:
- s390x
env:
- CGO_ENABLED=0
flags:
- -trimpath
ldflags:
- "-s -w -X main.version={{.Version}}"

archives:
-
format_overrides:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.17
FROM golang:1.21

RUN \
mkdir -p /licenses && \
Expand Down
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package main
import (
"context"
"flag"
"fmt"
"log"
"net"
"net/http"
Expand All @@ -35,6 +36,10 @@ import (
"github.com/rs/cors"
)

// Use e.g.: go build -ldflags "-X main.version=v1.0.0"
// to set the binary version.
var version = "0.0.0-dev"

// S3 - A S3 implements FileSystem using the minio client
// allowing access to your S3 buckets and objects.
//
Expand Down Expand Up @@ -134,9 +139,11 @@ var (
spaFile string
allowedCorsOrigin string
letsEncrypt bool
versionF = flag.Bool("version", false, "print version")
)

func init() {
flag.BoolVar(versionF, "v", false, "print version")
flag.StringVar(&endpoint, "endpoint", defaultEnvString("S3WWW_ENDPOINT", ""), "AWS S3 compatible server endpoint")
flag.StringVar(&bucket, "bucket", defaultEnvString("S3WWW_BUCKET", ""), "bucket name with static files")
flag.StringVar(&bucketPath, "bucketPath", defaultEnvString("S3WWW_BUCKET_PATH", "/"), "bucket path to serve static files from")
Expand Down Expand Up @@ -193,6 +200,11 @@ func NewCustomHTTPTransport() *http.Transport {
func main() {
flag.Parse()

if *versionF {
fmt.Println("s3www -", version)
os.Exit(0)
}

if strings.TrimSpace(bucket) == "" {
log.Fatalln(`Bucket name cannot be empty, please provide 's3www -bucket "mybucket"'`)
}
Expand Down

0 comments on commit 1740901

Please sign in to comment.