Skip to content

Commit

Permalink
君子修身养德
Browse files Browse the repository at this point in the history
  • Loading branch information
soulteary committed May 15, 2023
1 parent 9f50fc9 commit 04f8b9b
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Release

on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- 'v*'
env:
GO_VERSION: "1.20"

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
env:
GO111MODULE: on
DOCKER_CLI_EXPERIMENTAL: "enabled"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Cache Go modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Tests
run: |
go mod tidy
go test -v ./...
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
if: success() && startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67 changes: 67 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
project_name: coolshell

builds:
- <<: &build_defaults
env:
- CGO_ENABLED=0
ldflags:
- -w -s
id: macos
goos: [ darwin ]
goarch: [ amd64, arm64 ]

- <<: *build_defaults
id: linux
goos: [linux]
goarch: [amd64, arm64]

dockers:

- image_templates:
- "soulteary/forever-coolshell:linux-amd64-{{ .Tag }}"
- "soulteary/forever-coolshell:linux-amd64"
dockerfile: docker/Dockerfile.gorelease
use: buildx
goarch: amd64
build_flag_templates:
- "--pull"
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.description={{ .ProjectName }}"
- "--label=org.opencontainers.image.url=https://github.com/soulteary/forever-coolshell"
- "--label=org.opencontainers.image.source=https://github.com/soulteary/forever-coolshell"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"

- image_templates:
- "soulteary/forever-coolshell:linux-arm64-{{ .Tag }}"
- "soulteary/forever-coolshell:linux-arm64"
dockerfile: docker/Dockerfile.gorelease
use: buildx
goos: linux
goarch: arm64
goarm: ''
build_flag_templates:
- "--pull"
- "--platform=linux/arm64"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.description={{ .ProjectName }}"
- "--label=org.opencontainers.image.url=https://github.com/soulteary/forever-coolshell"
- "--label=org.opencontainers.image.source=https://github.com/soulteary/forever-coolshell"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"

docker_manifests:
- name_template: "soulteary/forever-coolshell:{{ .Tag }}"
image_templates:
- "soulteary/forever-coolshell:linux-amd64-{{ .Tag }}"
- "soulteary/forever-coolshell:linux-arm64-{{ .Tag }}"
skip_push: "false"

- name_template: "soulteary/forever-coolshell:latest"
image_templates:
- "soulteary/forever-coolshell:linux-amd64-{{ .Tag }}"
- "soulteary/forever-coolshell:linux-arm64-{{ .Tag }}"
skip_push: "false"
8 changes: 8 additions & 0 deletions docker/Dockerfile.gorelease
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM debian:bullseye as certs
RUN apt update && apt install -y ca-certificates

FROM scratch
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY coolshell /cool/shell
EXPOSE 8080/tcp
ENTRYPOINT ["/cool/shell"]

0 comments on commit 04f8b9b

Please sign in to comment.