Merge 06f78b4f8c7fdac49a9f4cc190e7f0c7a0a32ee3 into df72223a5fbd08673232a862567dcb44c6089cfc

This commit is contained in:
Ayman Bagabas 2022-02-12 13:22:22 +05:30 committed by GitHub
commit e654688162
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 234 additions and 24 deletions

48
.github/workflows/release.yml vendored Normal file
View File

@ -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
.gitignore vendored
View File

@ -4,4 +4,8 @@ host_key.pub
ssh-chat
*.log
.*
!.goreleaser.yml
!.github
vendor/
dist
sshchat

165
.goreleaser.yml Normal file
View File

@ -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 <andrey.petrov@shazow.net>
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

View File

@ -1,21 +0,0 @@
FROM golang:alpine AS builder
WORKDIR /usr/src/app
COPY . .
RUN apk add make openssh
RUN make build
FROM alpine
RUN apk add openssh
RUN mkdir /root/.ssh
WORKDIR /root/.ssh
RUN ssh-keygen -t rsa -C "chatkey" -f id_rsa
WORKDIR /usr/local/bin
COPY --from=builder /usr/src/app/ssh-chat .
RUN chmod +x ssh-chat
CMD ["/usr/local/bin/ssh-chat"]

6
Dockerfile.goreleaser Normal file
View File

@ -0,0 +1,6 @@
FROM scratch
COPY ssh-chat /usr/local/bin/ssh-chat
WORKDIR /sshchat
ENTRYPOINT [ "/usr/local/bin/ssh-chat" ]

View File

@ -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