Skip to content

Commit 1c43a50

Browse files
committed
add .github/workflows/release.yml for automated releases
Signed-off-by: Akihiro Suda <[email protected]>
1 parent 94b6247 commit 1c43a50

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- 'v*'
6+
- 'test-action-release-*'
7+
env:
8+
GO111MODULE: on
9+
jobs:
10+
release:
11+
strategy:
12+
matrix:
13+
go-version: [1.15.x]
14+
os: [ubuntu-20.04]
15+
runs-on: ${{ matrix.os }}
16+
timeout-minutes: 20
17+
steps:
18+
- uses: actions/setup-go@v2
19+
with:
20+
go-version: ${{ matrix.go-version }}
21+
- uses: actions/checkout@v2
22+
with:
23+
path: go/src/github.com/AkihiroSuda/sshocker
24+
- name: "Compile binaries"
25+
working-directory: go/src/github.com/AkihiroSuda/sshocker
26+
run: make cross
27+
- name: "SHA256SUMS"
28+
working-directory: go/src/github.com/AkihiroSuda/sshocker
29+
run: ( cd ./bin; sha256sum sshocker-* ) | tee /tmp/SHA256SUMS
30+
- name: "Prepare the release note"
31+
working-directory: go/src/github.com/AkihiroSuda/sshocker
32+
run: |
33+
tag="${GITHUB_REF##*/}"
34+
cat << EOF | tee /tmp/release-note.txt
35+
${tag}
36+
37+
#### Changes
38+
(To be documented)
39+
40+
#### Install
41+
\`\`\`
42+
curl -o sshocker --fail -L https://github.com/${{ github.repository }}/releases/download/${tag}/sshocker-\$(uname -s)-\$(uname -m)
43+
chmod +x sshocker
44+
\`\`\`
45+
46+
#### About the binaries
47+
The binaries were built automatically on GitHub Actions.
48+
See the log to verify SHA256SUMS.
49+
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
50+
EOF
51+
- name: "Create release"
52+
working-directory: go/src/github.com/AkihiroSuda/sshocker
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
run: |
56+
tag="${GITHUB_REF##*/}"
57+
asset_flags=()
58+
for f in ./bin/* /tmp/SHA256SUMS; do asset_flags+=("-a" "$f"); done
59+
hub release create "${asset_flags[@]}" -F /tmp/release-note.txt --draft "${tag}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.DEFAULT_GOAL := binary
2+
3+
GO := go
4+
5+
binary: bin/sshocker
6+
7+
install:
8+
cp -f bin/sshocker /usr/local/bin/sshocker
9+
10+
uninstall:
11+
rm -f /usr/local/bin/sshocker
12+
13+
bin/sshocker:
14+
CGO_ENABLED=0 $(GO) build -o $@ ./cmd/sshocker
15+
if [ $(shell go env GOOS) = linux ]; then LANG=C LC_ALL=C file $@ | grep -qw "statically linked"; fi
16+
17+
# The file name convention for Unix: ./bin/sshocker-$(uname -s)-$(uname -m)
18+
cross:
19+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -o ./bin/sshocker-Linux-x86_64 ./cmd/sshocker
20+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GO) build -o ./bin/sshocker-Linux-aarch64 ./cmd/sshocker
21+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GO) build -o ./bin/sshocker-Darwin-x86_64 ./cmd/sshocker
22+
23+
clean:
24+
rm -rf bin
25+
26+
.PHONY: binary install uninstall bin/sshocker cross clean

0 commit comments

Comments
 (0)