Add new Release Workflow using Github Actions and wangyoucao577/go-release-action

This commit is contained in:
Bernhard Froehlich
2021-02-17 12:49:24 +00:00
parent 7f34fcbc99
commit 5ba64c5c6e
4 changed files with 34 additions and 37 deletions

30
.github/workflows/release.yaml vendored Normal file
View File

@@ -0,0 +1,30 @@
name: Release Go Binaries
on:
release:
types: [created]
jobs:
releases-matrix:
name: Release Go Binary
runs-on: ubuntu-latest
strategy:
matrix:
goos: [freebsd, linux, windows]
goarch: ["386", amd64]
steps:
- uses: actions/checkout@v2
- name: Set APP_VERSION env
run: echo APP_VERSION=$(echo ${GITHUB_REF} | rev | cut -d'/' -f 1 | rev ) >> ${GITHUB_ENV}
- name: Set BUILD_TIME env
run: echo BUILD_TIME=$(date) >> ${GITHUB_ENV}
- uses: wangyoucao577/go-release-action@v1.14
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: "https://golang.org/dl/go1.15.8.linux-amd64.tar.gz"
extra_files: LICENSE README.md smtprelay.ini
ldflags: -s -w -X "main.appVersion=${{ env.APP_VERSION }}" -X "main.buildTime=${{ env.BUILD_TIME }}"

View File

@@ -6,8 +6,9 @@ import (
"github.com/vharitonsky/iniflags"
)
const (
VERSION = "1.4.0"
var (
appVersion = "unknown"
buildTime = "unknown"
)
var (

View File

@@ -234,7 +234,7 @@ func main() {
ConfigLoad()
if *versionInfo {
fmt.Printf("smtprelay/%s\n", VERSION)
fmt.Printf("smtprelay/%s (%s)\n", appVersion, buildTime)
os.Exit(0)
}

View File

@@ -1,34 +0,0 @@
#!/bin/sh
PROJECT=smtprelay
VERSION=1.3.0
for goos in freebsd linux windows
do
for goarch in 386 amd64
do
export GOOS=${goos}
export GOARCH=${goarch}
RELDIR=${PROJECT}-${VERSION}-${GOOS}-${GOARCH}
rm -rf ${RELDIR}
mkdir ${RELDIR} || exit 1
cp -p README.md LICENSE ${PROJECT}.ini ${RELDIR}/ || exit 1
if [ ${GOOS} = "windows" ]; then
BINARY=${PROJECT}.exe
sed -I '' -e 's/;logfile =.*/logfile =/g' ${RELDIR}/${PROJECT}.ini
sed -I '' -e 's/$/^M/' ${RELDIR}/${PROJECT}.ini
else
BINARY=${PROJECT}
fi
go build -ldflags="-s -w" -o ${RELDIR}/${BINARY} || exit 1
chown -R root:wheel ${RELDIR} || exit 1
tar cvfJ ${RELDIR}.tar.xz ${RELDIR} || exit 1
rm -rf ${RELDIR}
done
done