Skip to content

Commit 66e6dd0

Browse files
committed
Release: Use GoReleaser for release
- use github actions and goreleaser to automatically build and publish release on new tags - build binaries - build dep/rpm packages for linux - build docker images tagged with release version and 'latest' tag - publish release on github releases - publish docker images on github container registry - replace `Dockerfile` with `Dockerfile.goreleaser` - update `docker-compose.yml` to use `ghcr.io`
1 parent 7628a47 commit 66e6dd0

File tree

6 files changed

+179
-24
lines changed

6 files changed

+179
-24
lines changed

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
goreleaser:
14+
runs-on: ubuntu-latest
15+
steps:
16+
-
17+
name: Checkout
18+
uses: actions/checkout@v2
19+
with:
20+
fetch-depth: 0
21+
-
22+
name: Set up Go
23+
uses: actions/setup-go@v2
24+
with:
25+
go-version: 1.17
26+
27+
28+
- name: Login to GitHub Container Registry
29+
uses: docker/login-action@v1
30+
with:
31+
registry: ghcr.io
32+
username: ${{ github.repository_owner }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Run GoReleaser
36+
uses: goreleaser/goreleaser-action@v2
37+
with:
38+
distribution: goreleaser
39+
version: latest
40+
args: release --rm-dist
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ host_key.pub
44
ssh-chat
55
*.log
66
.*
7+
!.goreleaser.yml
8+
!.github
79
vendor/
10+
dist
11+
sshchat

.goreleaser.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
project_name: ssh-chat
2+
3+
env:
4+
- GO111MODULE=on
5+
- CGO_ENABLED=0
6+
7+
before:
8+
hooks:
9+
- go mod download
10+
11+
builds:
12+
- id: "ssh-chat"
13+
dir: "./cmd/ssh-chat"
14+
binary: "ssh-chat"
15+
ldflags: -X main.Version={{ .Version }} -extldflags "-static"
16+
goos:
17+
- linux
18+
- windows
19+
- freebsd
20+
- darwin
21+
goarch:
22+
- amd64
23+
- 386
24+
- arm
25+
- arm64
26+
goarm:
27+
- 7
28+
ignore:
29+
- goos: darwin
30+
goarch: 386
31+
- goos: darwin
32+
goarch: arm
33+
- goos: freebsd
34+
goarch: 386
35+
- goos: freebsd
36+
goarch: arm
37+
- goos: freebsd
38+
goarch: arm64
39+
- goos: windows
40+
goarch: arm
41+
- goos: windows
42+
goarch: arm64
43+
44+
dockers:
45+
- image_templates:
46+
- "ghcr.io/shazow/ssh-chat:latest"
47+
- "ghcr.io/shazow/ssh-chat:{{ .Version }}"
48+
ids: [ssh-chat]
49+
goarch: amd64
50+
build_flag_templates:
51+
- --platform=linux/amd64
52+
- --label=org.opencontainers.image.title={{ .ProjectName }}
53+
- --label=org.opencontainers.image.description={{ .ProjectName }}
54+
- --label=org.opencontainers.image.url=https://github.com/shazow/ssh-chat
55+
- --label=org.opencontainers.image.source=https://github.com/shazow/ssh-chat
56+
- --label=org.opencontainers.image.version={{ .Version }}
57+
- --label=org.opencontainers.image.created={{ .Date }}
58+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
59+
- --label=org.opencontainers.image.licenses=MIT
60+
dockerfile: Dockerfile.goreleaser
61+
use: buildx
62+
- image_templates:
63+
- "ghcr.io/shazow/ssh-chat:latest"
64+
- "ghcr.io/shazow/ssh-chat:{{ .Version }}"
65+
ids: [ssh-chat]
66+
goarch: arm64
67+
build_flag_templates:
68+
- --platform=linux/arm64
69+
- --label=org.opencontainers.image.title={{ .ProjectName }}
70+
- --label=org.opencontainers.image.description={{ .ProjectName }}
71+
- --label=org.opencontainers.image.url=https://github.com/shazow/ssh-chat
72+
- --label=org.opencontainers.image.source=https://github.com/shazow/ssh-chat
73+
- --label=org.opencontainers.image.version={{ .Version }}
74+
- --label=org.opencontainers.image.created={{ .Date }}
75+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
76+
- --label=org.opencontainers.image.licenses=MIT
77+
dockerfile: Dockerfile.goreleaser
78+
use: buildx
79+
80+
nfpms:
81+
- maintainer: Andrey Petrov <[email protected]>
82+
description: "{{ .ProjectName }}"
83+
homepage: https://github.com/shazow/ssh-chat
84+
license: MIT
85+
formats:
86+
- deb
87+
- rpm
88+
89+
archives:
90+
- id: ssh-chat
91+
builds:
92+
- ssh-chat
93+
format: tar.gz
94+
format_overrides:
95+
- goos: windows
96+
format: zip
97+
files:
98+
- LICENSE*
99+
- README*
100+
- CHANGELOG*
101+
- dist/*.deb
102+
- dist/*.rpm
103+
104+
release:
105+
github:
106+
owner: shazow
107+
name: ssh-chat
108+
ids: [ssh-chat]
109+
prerelease: auto
110+
111+
changelog:
112+
sort: asc
113+
filters:
114+
exclude:
115+
- '^docs:'
116+
- typo

Dockerfile

Lines changed: 0 additions & 21 deletions
This file was deleted.

Dockerfile.goreleaser

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM scratch
2+
3+
COPY ssh-chat /usr/local/bin/ssh-chat
4+
WORKDIR /sshchat
5+
6+
ENTRYPOINT [ "/usr/local/bin/ssh-chat" ]

docker-compose.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
version: '3'
1+
version: '3.7'
22
services:
3-
app:
4-
build: .
3+
ssh-chat:
4+
image: ghcr.io/shazow/ssh-chat:latest
55
ports:
66
- 2022:2022
77
restart: always
8+
volumes:
9+
- ./sshchat:/sshchat
10+
command:
11+
- --verbose
12+
- --identity=id
13+
- --bind=":2022"
14+
- --admin=admins
15+
- --motd=motd

0 commit comments

Comments
 (0)