Skip to content

Release: Use GoReleaser for release #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release

on:
push:
tags:
- 'v*.*'

permissions:
contents: write
packages: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17


- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload assets
uses: actions/upload-artifact@v2
with:
name: ssh-chat
path: dist/*.*
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ host_key.pub
ssh-chat
*.log
.*
!.goreleaser.yml
!.github
vendor/
dist
sshchat
165 changes: 165 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
project_name: ssh-chat

env:
- GO111MODULE=on
- CGO_ENABLED=0

before:
hooks:
- go mod download

builds:
- id: "ssh-chat"
dir: "./cmd/ssh-chat"
binary: "ssh-chat"
ldflags: -X main.Version={{ .Version }} -extldflags "-static"
goos:
- linux
- windows
- freebsd
- darwin
goarch:
- amd64
- 386
- arm
- arm64
goarm:
- 6
- 7
ignore:
- goos: darwin
goarch: 386
- goos: darwin
goarch: arm
- goos: freebsd
goarch: 386
- goos: freebsd
goarch: arm
- goos: freebsd
goarch: arm64
- goos: windows
goarch: arm
- goos: windows
goarch: arm64

dockers:
- image_templates:
- "ghcr.io/shazow/{{ .ProjectName }}:latest-amd64"
- "ghcr.io/shazow/{{ .ProjectName }}:{{ .Version }}-amd64"
ids: [ssh-chat]
goarch: amd64
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/shazow/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/shazow/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ .Date }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
dockerfile: Dockerfile.goreleaser
use: buildx
- image_templates:
- "ghcr.io/shazow/{{ .ProjectName }}:latest-arm64v8"
- "ghcr.io/shazow/{{ .ProjectName }}:{{ .Version }}-arm64v8"
ids: [ssh-chat]
goarch: arm64
build_flag_templates:
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/shazow/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/shazow/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ .Date }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
dockerfile: Dockerfile.goreleaser
use: buildx
- image_templates:
- "ghcr.io/shazow/{{ .ProjectName }}:latest-arm32v6"
- "ghcr.io/shazow/{{ .ProjectName }}:{{ .Version }}-arm32v6"
ids: [ssh-chat]
goarch: arm
goarm: 6
build_flag_templates:
- --platform=linux/arm/v6
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/shazow/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/shazow/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ .Date }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
dockerfile: Dockerfile.goreleaser
use: buildx
- image_templates:
- "ghcr.io/shazow/{{ .ProjectName }}:latest-arm32v7"
- "ghcr.io/shazow/{{ .ProjectName }}:{{ .Version }}-arm32v7"
ids: [ssh-chat]
goarch: arm
goarm: 7
build_flag_templates:
- --platform=linux/arm/v7
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/shazow/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/shazow/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ .Date }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
dockerfile: Dockerfile.goreleaser
use: buildx

docker_manifests:
- name_template: ghcr.io/shazow/{{ .ProjectName }}:latest
image_templates:
- ghcr.io/shazow/{{ .ProjectName }}:latest-amd64
- ghcr.io/shazow/{{ .ProjectName }}:latest-arm64v8
- ghcr.io/shazow/{{ .ProjectName }}:latest-arm32v7
- ghcr.io/shazow/{{ .ProjectName }}:latest-arm32v6
- name_template: ghcr.io/shazow/{{ .ProjectName }}:{{ .Version }}
image_templates:
- ghcr.io/shazow/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/shazow/{{ .ProjectName }}:{{ .Version }}-arm64v8
- ghcr.io/shazow/{{ .ProjectName }}:{{ .Version }}-arm32v7
- ghcr.io/shazow/{{ .ProjectName }}:{{ .Version }}-arm32v6

nfpms:
- maintainer: Andrey Petrov <[email protected]>
description: "{{ .ProjectName }}"
homepage: https://github.com/shazow/{{ .ProjectName }}
license: MIT
formats:
- deb
- rpm

archives:
- id: ssh-chat
builds:
- ssh-chat
format: tar.gz
format_overrides:
- goos: windows
format: zip
files:
- LICENSE*
- README*
- CHANGELOG*

release:
github:
owner: shazow
name: ssh-chat
ids: [ssh-chat]
prerelease: auto

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- typo
21 changes: 0 additions & 21 deletions Dockerfile

This file was deleted.

6 changes: 6 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM scratch

COPY ssh-chat /usr/local/bin/ssh-chat
WORKDIR /sshchat

ENTRYPOINT [ "/usr/local/bin/ssh-chat" ]
14 changes: 11 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
version: '3'
version: '3.7'
services:
app:
build: .
ssh-chat:
image: ghcr.io/shazow/ssh-chat:latest
ports:
- 2022:2022
restart: always
volumes:
- ./sshchat:/sshchat
command:
- --verbose
- --identity=id
- --bind=":2022"
- --admin=admins
- --motd=motd