go1.18 and nbgv
This commit is contained in:
parent
f14ff4278b
commit
76c8d6d0bb
5 changed files with 46 additions and 36 deletions
6
.github/workflows/docker-publish.yml
vendored
6
.github/workflows/docker-publish.yml
vendored
|
|
@ -30,6 +30,10 @@ jobs:
|
|||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: dotnet/nbgv@master
|
||||
with:
|
||||
setAllVars: true
|
||||
|
||||
# Login against a Docker registry except on PR
|
||||
# https://github.com/docker/login-action
|
||||
- name: Log into registry ${{ env.REGISTRY }}
|
||||
|
|
@ -55,6 +59,8 @@ jobs:
|
|||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
build-args:
|
||||
- VER=${{ env.NBGV_SimpleVersion }}
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
|
|
|||
24
Dockerfile
24
Dockerfile
|
|
@ -1,29 +1,19 @@
|
|||
FROM golang:1.17-alpine as builder
|
||||
FROM golang:1.18-stretch as builder
|
||||
|
||||
RUN apk update \
|
||||
&& apk upgrade \
|
||||
&& apk add --no-cache \
|
||||
ca-certificates git \
|
||||
&& update-ca-certificates 2>/dev/null
|
||||
ARG VER=devel
|
||||
|
||||
ADD . /go/src/github.com/tg123/sshpiper/
|
||||
WORKDIR /go/src/github.com/tg123/sshpiper/sshpiperd
|
||||
RUN CGO_ENABLED=0 go build -ldflags "$(/go/src/github.com/tg123/sshpiper/sshpiperd/ldflags.sh)" -o /go/bin/sshpiperd
|
||||
ADD . /src/
|
||||
WORKDIR /src/sshpiperd
|
||||
RUN CGO_ENABLED=0 go build -ldflags "-X main.version=$VER" -o /sshpiperd
|
||||
|
||||
|
||||
FROM alpine:latest
|
||||
FROM busybox
|
||||
LABEL maintainer="Boshi Lian<farmer1992@gmail.com>"
|
||||
|
||||
RUN apk update \
|
||||
&& apk upgrade \
|
||||
&& apk add --no-cache \
|
||||
ca-certificates \
|
||||
&& update-ca-certificates 2>/dev/null
|
||||
|
||||
RUN mkdir /etc/ssh/
|
||||
|
||||
ADD entrypoint.sh /
|
||||
COPY --from=builder /go/bin/sshpiperd /
|
||||
COPY --from=builder /sshpiperd /
|
||||
EXPOSE 2222
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd $GOPATH/src/github.com/tg123/sshpiper
|
||||
|
||||
githash=`git log --pretty=format:%h,%ad --name-only --date=short . | head -n 1`
|
||||
ver=`cat ver`
|
||||
|
||||
echo "-X main.version=$ver -X main.githash=$githash"
|
||||
|
|
@ -2,12 +2,11 @@ package main
|
|||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var version = "DEV"
|
||||
var githash = "0000000000"
|
||||
var version = "(devel)"
|
||||
|
||||
func showVersion() {
|
||||
versionTemplate := template.Must(template.New("ver").Parse(`
|
||||
|
|
@ -17,15 +16,31 @@ https://github.com/tg123/sshpiper
|
|||
Version : {{.VER}}
|
||||
Go Runtime : {{.GOVER}}
|
||||
Git Commit : {{.GITHASH}}
|
||||
Timestamp : {{.TIMESTAMP}}
|
||||
`[1:]))
|
||||
|
||||
_ = versionTemplate.Execute(os.Stdout, struct {
|
||||
VER string
|
||||
GOVER string
|
||||
GITHASH string
|
||||
data := struct {
|
||||
VER string
|
||||
GOVER string
|
||||
GITHASH string
|
||||
TIMESTAMP string
|
||||
}{
|
||||
VER: version,
|
||||
GITHASH: githash,
|
||||
GOVER: runtime.Version(),
|
||||
})
|
||||
VER: version,
|
||||
}
|
||||
|
||||
bi, ok := debug.ReadBuildInfo()
|
||||
if ok {
|
||||
for _, s := range bi.Settings {
|
||||
switch s.Key {
|
||||
case "vcs.revision":
|
||||
data.GITHASH = s.Value[:9]
|
||||
case "vcs.time":
|
||||
data.TIMESTAMP = s.Value
|
||||
}
|
||||
}
|
||||
|
||||
data.GOVER = bi.GoVersion
|
||||
}
|
||||
|
||||
_ = versionTemplate.Execute(os.Stdout, data)
|
||||
}
|
||||
|
|
|
|||
7
version.json
Normal file
7
version.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
|
||||
"version": "0.7",
|
||||
"publicReleaseRefSpec": [
|
||||
"^refs/heads/master$"
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue