-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (79 loc) · 2.5 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: build-release-binary
run-name: Create Github Release for GoLang binary
on:
push:
#branches:
#- main
tags:
- 'r*'
jobs:
build:
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
# debug
- name: Dump env
run: env | sort
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
with:
fetch-depth: 0 # get all tags, needed to get git log
ref: main
# Go environment
- name: setup Go Lang
id: build
uses: actions/setup-go@v3
with:
go-version: '^1.19.2'
- run: |
go version
cd ./cmd/httpbench/
mkdir builds
ls -lisa
if [ ! -e *.mod ]; then
go mod init ${GITHUB_REPOSITORY}
fi
go mod tidy
go build -o httpbench -ldflags "-X main.Version=${GITHUB_REF_NAME} -X main.BuiltBy=github-actions" main.go
mv httpbench builds/
ls -lisa builds/
- run: git version
- run: git branch
- run: git tag
- name: get semantic tag version and release notes from commit messages
id: tag
run: |
currentTag=${GITHUB_REF_NAME}
major_minor=$(echo "$currentTag" | cut -d'.' -f1-2)
patch=$currentTag
# avoid empty patch number
[ -n "$patch" ] && ((patch--)) || patch=".x"
previousTag="${major_minor}.${patch}"
echo "" > body.log
if git tag | grep $previousTag ; then
git log -q ${currentTag}...${previousTag} --pretty="- %s" -q --no-color >> body.log
else
git log --pretty="- %s" -q --no-color >> body.log
fi
line_count=$(cat body.log | wc -l)
echo "currentTag=$currentTag" >> $GITHUB_OUTPUT
echo "previousTag=$previousTag" >> $GITHUB_OUTPUT
echo "line_count=$line_count" >> $GITHUB_OUTPUT
- run: echo currentTag is ${{ steps.tag.outputs.currentTag }}
- run: echo previousTag is ${{ steps.tag.outputs.previousTag }}
- run: echo line_count is ${{ steps.tag.outputs.line_count }}
- run: cat body.log
# create Github release with release note from file and binary asset attached
- uses: ncipollo/release-action@v1
with:
name: ${{ env.GITHUB_REF_NAME }}
tag: ${{ env.GITHUB_REF_NAME }}
artifacts: ./cmd/httpbench/builds/httpbench
bodyFile: "body.log"
token: ${{ secrets.GITHUB_TOKEN }}
removeArtifacts: true
allowUpdates: "true"