Skip to content

Commit

Permalink
Merge pull request #6 from to-lz1/add_releaser
Browse files Browse the repository at this point in the history
release m3dev/dsps binary by goreleaser
  • Loading branch information
hirosassa authored Jul 1, 2022
2 parents 3f5167e + 7371ba0 commit 1f2261d
Show file tree
Hide file tree
Showing 210 changed files with 561 additions and 642 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/release-latest.yaml

This file was deleted.

130 changes: 33 additions & 97 deletions .github/workflows/release-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,107 +5,43 @@ on:
- 'v*'

jobs:
docker-images:
name: Publish docker images
goreleaser:
runs-on: ubuntu-latest
steps:
- id: get-tag
run: |
tag=$(echo "${{github.ref}}" | sed 's/^refs\/tags\/v//')
echo "::set-output name=tag::$tag"
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
go-version: 1.18.3
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
context: ./server
file: ./server/Dockerfile # file is not relative to context https://github.com/docker/build-push-action/issues/51#issuecomment-702506036
platforms: linux/amd64,linux/arm64
push: true
tags: saiya/dsps:${{ steps.get-tag.outputs.tag }}
build-args: |
DSPS_VERSION_ID=${{ steps.get-tag.outputs.tag }}
js-client-npm-release:
name: Publish JS client
runs-on: ubuntu-latest
steps:
- id: get-version
run: |
version=$(echo "${{github.ref}}" | sed 's/^refs\/tags\/v//')
echo "::set-output name=version::$version"
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
scope: '@dsps'
- name: Yarn publish
run: |
yarn install --frozen-lockfile
yarn publish --frozen-lockfile --non-interactive --new-version ${{ steps.get-version.outputs.version }} --no-git-tag-version
working-directory: client/js
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

github-release:
name: Create GitHub release
runs-on: ubuntu-latest
steps:
- id: get-tag
run: |
tag=$(echo "${{github.ref}}" | sed 's/^refs\/tags\/v//')
echo "::set-output name=tag::$tag"
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.18.3'
- name: Build
run: |
go install
make build
working-directory: server
env:
DSPS_VERSION_ID: ${{ steps.get-tag.outputs.tag }}

# https://zenn.dev/seita/articles/d1dba77043be8fd50eeb
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Get commit summary
id: get_commit_summary
run: |
PREVIOUS_TAG=$(git tag --sort=-creatordate | sed -n 2p)
echo "PREVIOUS_TAG: $PREVIOUS_TAG"
COMMIT_SUMMARY="$(git log --oneline --pretty=tformat:"%h %s" $PREVIOUS_TAG..${{ github.ref }})"
COMMIT_SUMMARY="${COMMIT_SUMMARY//$'\n'/'%0A'}"
echo ::set-output name=COMMIT_SUMMARY::$COMMIT_SUMMARY
- id: create_release
uses: actions/create-release@v1
version: latest
workdir: server
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ steps.get_commit_summary.outputs.COMMIT_SUMMARY }}
draft: true
prerelease: true
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./server/dsps.zip
asset_name: dsps.zip
asset_content_type: application/zip

# js-client-npm-release:
# name: Publish JS client
# runs-on: ubuntu-latest
# steps:
# - id: get-version
# run: |
# version=$(echo "${{github.ref}}" | sed 's/^refs\/tags\/v//')
# echo "::set-output name=version::$version"
# - name: Checkout
# uses: actions/checkout@v2
# - uses: actions/setup-node@v1
# with:
# node-version: '12.x'
# registry-url: 'https://registry.npmjs.org'
# scope: '@dsps'
# - name: Yarn publish
# run: |
# yarn install --frozen-lockfile
# yarn publish --frozen-lockfile --non-interactive --new-version ${{ steps.get-version.outputs.version }} --no-git-tag-version
# working-directory: client/js
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
15 changes: 9 additions & 6 deletions .github/workflows/server-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ jobs:
go mod download
make generate
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: v1.46.2
working-directory: server
skip-pkg-cache: true
- name: Other Lint
shell: bash
working-directory: server
Expand Down Expand Up @@ -96,8 +97,10 @@ jobs:
with:
go-version: ${{ env.go-version }}
- name: build
shell: bash
working-directory: server
run: |
go mod download
make build
uses: goreleaser/goreleaser-action@v2
with:
version: latest
workdir: server
args: build --rm-dist --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
![DSPS Banner](./img/logo/DSPS.svg)

[![MIT License](https://img.shields.io/badge/LICENSE-MIT-brightgreen)](./LICENSE)
[![Server Test](https://github.com/saiya/dsps/workflows/Server%20Test/badge.svg?1)](https://github.com/saiya/dsps/actions?query=workflow%3A%22Server+Test%22)
[![Codecov](https://codecov.io/gh/saiya/dsps/branch/main/graph/badge.svg?token=DSSOWMB60X)](https://codecov.io/gh/saiya/dsps)
[![Go Report Card](https://goreportcard.com/badge/github.com/saiya/dsps?1)](https://goreportcard.com/report/github.com/saiya/dsps)
[![DockerHub saiya/dsps](https://img.shields.io/badge/dockerhub-saiya%2Fdsps-blue)](https://hub.docker.com/r/saiya/dsps/tags?page=1&ordering=last_updated)
[![Server Test](https://github.com/m3dev/dsps/workflows/Server%20Test/badge.svg?1)](https://github.com/m3dev/dsps/actions?query=workflow%3A%22Server+Test%22)
[![Codecov](https://codecov.io/gh/m3dev/dsps/branch/main/graph/badge.svg)](https://codecov.io/gh/m3dev/dsps)
[![Go Report Card](https://goreportcard.com/badge/github.com/m3dev/dsps?1)](https://goreportcard.com/report/github.com/m3dev/dsps)
[![npm version](https://badge.fury.io/js/%40dsps%2Fclient.svg)](https://badge.fury.io/js/%40dsps%2Fclient)

---
Expand Down Expand Up @@ -38,8 +37,8 @@ Note that DSPS does not aim to provide followings:
## 3 minutes to getting started with DSPS

```sh
# Download & run DSPS server
docker run --rm -p 3099:3000/tcp saiya/dsps:latest
# Build & run DSPS server
docker build . -t dsps-getting-started && docker run --rm -p 3099:3000/tcp dsps-getting-started

#
# ... Open another terminal window to run following tutorial ...
Expand Down
5 changes: 3 additions & 2 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/dsps.zip

/coverage*
/pprof

# Temporary file in Makefile
/go.mod.bak

dist/
CREDITS
38 changes: 38 additions & 0 deletions server/.goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
before:
hooks:
- go install github.com/golang/mock/mockgen@latest
- go install github.com/Songmu/gocredits/cmd/gocredits@latest
- go generate ./...
- go mod tidy
- gocredits -w -skip-missing .
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
archives:
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
files:
- CHANGELOG*
- CREDITS
- README*
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
release:
prerelease: true
2 changes: 1 addition & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG DSPS_VERSION_ID=""
WORKDIR /go/src/github.com/dsps/server
COPY . .
RUN go install && go install github.com/Songmu/gocredits/cmd/gocredits
RUN make dsps/dsps-$(uname -o | sed 's/GNU\///')-$(uname -m) && mv dsps/dsps-$(uname -o | sed 's/GNU\///')-$(uname -m) /dsps.bin
RUN make dist/dsps-$(uname -o | sed 's/GNU\///')-$(uname -m) && mv dist/dsps-$(uname -o | sed 's/GNU\///')-$(uname -m) /dsps.bin

FROM alpine:3.12.3
# Add some utilities for convinience: gettext (contains envsubst), curl, jq
Expand Down
16 changes: 3 additions & 13 deletions server/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
SHELL := /bin/bash

release_dir = dsps
release_dir = dist
go_module_files = go.mod go.sum
go_src_files = $(shell find . -type f -name '*.go')
build_deps = $(go_module_files) $(go_src_files) | $(release_dir)

DSPS_VERSION_ID ?= $(shell git rev-list -1 HEAD)
ldflags = "-X main.buildVersion=$(DSPS_VERSION_ID) -X main.buildAt=$(shell date +'%s')"

.PHONY: build test test.profile lint generate

build: $(release_dir).zip
.PHONY: test test.profile lint generate

test: generate
GIN_MODE=release go test -v -race -timeout 30m -coverprofile=coverage.txt -covermode=atomic ./...
Expand All @@ -36,16 +34,8 @@ generate:
go install github.com/golang/mock/mockgen
go generate ./...

$(release_dir).zip: $(release_dir)/README.md $(release_dir)/CREDITS $(release_dir)/dsps-Linux-x86_64 $(release_dir)/dsps-Linux-aarch64 $(release_dir)/dsps-Windows-x86_64.exe $(release_dir)/dsps-Darwin-x86_64
zip -r $@ $(release_dir)/ -x '$(release_dir)/.gitignore'

$(release_dir):
mkdir $(release_dir)

$(release_dir)/CREDITS: $(go_module_files) | $(release_dir)
go install github.com/Songmu/gocredits/cmd/gocredits
rm -f $@
gocredits -skip-missing . > $@
mkdir -p $(release_dir)

$(release_dir)/dsps-Linux-x86_64: $(build_deps)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ -ldflags "-X main.BuildDist=linux-amd64" -ldflags $(ldflags) main.go
Expand Down
2 changes: 1 addition & 1 deletion server/config/admin_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/google/uuid"
"golang.org/x/xerrors"

"github.com/saiya/dsps/server/domain"
"github.com/m3dev/dsps/server/domain"
)

// AdminConfig represents administration feature settings
Expand Down
4 changes: 2 additions & 2 deletions server/config/admin_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/stretchr/testify/assert"

. "github.com/saiya/dsps/server/config"
"github.com/saiya/dsps/server/domain"
. "github.com/m3dev/dsps/server/config"
"github.com/m3dev/dsps/server/domain"
)

func TestAdminDefaultConfig(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion server/config/channel_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config
import (
"fmt"

"github.com/saiya/dsps/server/domain"
"github.com/m3dev/dsps/server/domain"
)

var channlesConfigDefault = ChannelsConfig{
Expand Down
4 changes: 2 additions & 2 deletions server/config/channel_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/stretchr/testify/assert"

. "github.com/saiya/dsps/server/config"
. "github.com/saiya/dsps/server/testing"
. "github.com/m3dev/dsps/server/config"
. "github.com/m3dev/dsps/server/testing"
)

func TestChannelDefaultConfig(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/go-playground/validator/v10"
goyaml "github.com/goccy/go-yaml"

"github.com/saiya/dsps/server/domain"
"github.com/m3dev/dsps/server/domain"
)

// Overrides is to override configuration file.
Expand Down
4 changes: 2 additions & 2 deletions server/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/stretchr/testify/assert"

. "github.com/saiya/dsps/server/config"
. "github.com/saiya/dsps/server/testing"
. "github.com/m3dev/dsps/server/config"
. "github.com/m3dev/dsps/server/testing"
)

func TestTabInYaml(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion server/config/http_server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/saiya/dsps/server/domain"
"github.com/m3dev/dsps/server/domain"
)

// HTTPServerConfig represents HTTP webserver settings
Expand Down
Loading

0 comments on commit 1f2261d

Please sign in to comment.