Skip to content

Commit 1f2261d

Browse files
authored
Merge pull request #6 from to-lz1/add_releaser
release m3dev/dsps binary by goreleaser
2 parents 3f5167e + 7371ba0 commit 1f2261d

210 files changed

Lines changed: 561 additions & 642 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/release-latest.yaml

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

.github/workflows/release-tag.yaml

Lines changed: 33 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -5,107 +5,43 @@ on:
55
- 'v*'
66

77
jobs:
8-
docker-images:
9-
name: Publish docker images
8+
goreleaser:
109
runs-on: ubuntu-latest
1110
steps:
12-
- id: get-tag
13-
run: |
14-
tag=$(echo "${{github.ref}}" | sed 's/^refs\/tags\/v//')
15-
echo "::set-output name=tag::$tag"
1611
- name: Checkout
17-
uses: actions/checkout@v2
18-
- name: Set up QEMU
19-
uses: docker/setup-qemu-action@v1
20-
- name: Set up Docker Buildx
21-
uses: docker/setup-buildx-action@v1
22-
- name: Login to DockerHub
23-
uses: docker/login-action@v1
12+
uses: actions/checkout@v3
13+
- name: Setup Go
14+
uses: actions/setup-go@v3
2415
with:
25-
username: ${{ secrets.DOCKERHUB_USERNAME }}
26-
password: ${{ secrets.DOCKERHUB_TOKEN }}
27-
- name: Build and push
28-
uses: docker/build-push-action@v2
16+
go-version: 1.18.3
17+
- name: Run GoReleaser
18+
uses: goreleaser/goreleaser-action@v2
2919
with:
30-
context: ./server
31-
file: ./server/Dockerfile # file is not relative to context https://github.com/docker/build-push-action/issues/51#issuecomment-702506036
32-
platforms: linux/amd64,linux/arm64
33-
push: true
34-
tags: saiya/dsps:${{ steps.get-tag.outputs.tag }}
35-
build-args: |
36-
DSPS_VERSION_ID=${{ steps.get-tag.outputs.tag }}
37-
38-
js-client-npm-release:
39-
name: Publish JS client
40-
runs-on: ubuntu-latest
41-
steps:
42-
- id: get-version
43-
run: |
44-
version=$(echo "${{github.ref}}" | sed 's/^refs\/tags\/v//')
45-
echo "::set-output name=version::$version"
46-
- name: Checkout
47-
uses: actions/checkout@v2
48-
- uses: actions/setup-node@v1
49-
with:
50-
node-version: '12.x'
51-
registry-url: 'https://registry.npmjs.org'
52-
scope: '@dsps'
53-
- name: Yarn publish
54-
run: |
55-
yarn install --frozen-lockfile
56-
yarn publish --frozen-lockfile --non-interactive --new-version ${{ steps.get-version.outputs.version }} --no-git-tag-version
57-
working-directory: client/js
58-
env:
59-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
60-
61-
github-release:
62-
name: Create GitHub release
63-
runs-on: ubuntu-latest
64-
steps:
65-
- id: get-tag
66-
run: |
67-
tag=$(echo "${{github.ref}}" | sed 's/^refs\/tags\/v//')
68-
echo "::set-output name=tag::$tag"
69-
- uses: actions/checkout@v2
70-
- uses: actions/setup-go@v2
71-
with:
72-
go-version: '1.18.3'
73-
- name: Build
74-
run: |
75-
go install
76-
make build
77-
working-directory: server
78-
env:
79-
DSPS_VERSION_ID: ${{ steps.get-tag.outputs.tag }}
80-
81-
# https://zenn.dev/seita/articles/d1dba77043be8fd50eeb
82-
- name: Get the version
83-
id: get_version
84-
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
85-
- name: Get commit summary
86-
id: get_commit_summary
87-
run: |
88-
PREVIOUS_TAG=$(git tag --sort=-creatordate | sed -n 2p)
89-
echo "PREVIOUS_TAG: $PREVIOUS_TAG"
90-
COMMIT_SUMMARY="$(git log --oneline --pretty=tformat:"%h %s" $PREVIOUS_TAG..${{ github.ref }})"
91-
COMMIT_SUMMARY="${COMMIT_SUMMARY//$'\n'/'%0A'}"
92-
echo ::set-output name=COMMIT_SUMMARY::$COMMIT_SUMMARY
93-
94-
- id: create_release
95-
uses: actions/create-release@v1
20+
version: latest
21+
workdir: server
22+
args: release --rm-dist
9623
env:
9724
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98-
with:
99-
tag_name: ${{ github.ref }}
100-
release_name: Release ${{ github.ref }}
101-
body: ${{ steps.get_commit_summary.outputs.COMMIT_SUMMARY }}
102-
draft: true
103-
prerelease: true
104-
- uses: actions/upload-release-asset@v1
105-
env:
106-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107-
with:
108-
upload_url: ${{ steps.create_release.outputs.upload_url }}
109-
asset_path: ./server/dsps.zip
110-
asset_name: dsps.zip
111-
asset_content_type: application/zip
25+
26+
# js-client-npm-release:
27+
# name: Publish JS client
28+
# runs-on: ubuntu-latest
29+
# steps:
30+
# - id: get-version
31+
# run: |
32+
# version=$(echo "${{github.ref}}" | sed 's/^refs\/tags\/v//')
33+
# echo "::set-output name=version::$version"
34+
# - name: Checkout
35+
# uses: actions/checkout@v2
36+
# - uses: actions/setup-node@v1
37+
# with:
38+
# node-version: '12.x'
39+
# registry-url: 'https://registry.npmjs.org'
40+
# scope: '@dsps'
41+
# - name: Yarn publish
42+
# run: |
43+
# yarn install --frozen-lockfile
44+
# yarn publish --frozen-lockfile --non-interactive --new-version ${{ steps.get-version.outputs.version }} --no-git-tag-version
45+
# working-directory: client/js
46+
# env:
47+
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/server-test.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ jobs:
2222
go mod download
2323
make generate
2424
- name: golangci-lint
25-
uses: golangci/golangci-lint-action@v2
25+
uses: golangci/golangci-lint-action@v3
2626
with:
2727
version: v1.46.2
2828
working-directory: server
29+
skip-pkg-cache: true
2930
- name: Other Lint
3031
shell: bash
3132
working-directory: server
@@ -96,8 +97,10 @@ jobs:
9697
with:
9798
go-version: ${{ env.go-version }}
9899
- name: build
99-
shell: bash
100-
working-directory: server
101-
run: |
102-
go mod download
103-
make build
100+
uses: goreleaser/goreleaser-action@v2
101+
with:
102+
version: latest
103+
workdir: server
104+
args: build --rm-dist --snapshot
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
![DSPS Banner](./img/logo/DSPS.svg)
44

55
[![MIT License](https://img.shields.io/badge/LICENSE-MIT-brightgreen)](./LICENSE)
6-
[![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)
7-
[![Codecov](https://codecov.io/gh/saiya/dsps/branch/main/graph/badge.svg?token=DSSOWMB60X)](https://codecov.io/gh/saiya/dsps)
8-
[![Go Report Card](https://goreportcard.com/badge/github.com/saiya/dsps?1)](https://goreportcard.com/report/github.com/saiya/dsps)
9-
[![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)
6+
[![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)
7+
[![Codecov](https://codecov.io/gh/m3dev/dsps/branch/main/graph/badge.svg)](https://codecov.io/gh/m3dev/dsps)
8+
[![Go Report Card](https://goreportcard.com/badge/github.com/m3dev/dsps?1)](https://goreportcard.com/report/github.com/m3dev/dsps)
109
[![npm version](https://badge.fury.io/js/%40dsps%2Fclient.svg)](https://badge.fury.io/js/%40dsps%2Fclient)
1110

1211
---
@@ -38,8 +37,8 @@ Note that DSPS does not aim to provide followings:
3837
## 3 minutes to getting started with DSPS
3938

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

4443
#
4544
# ... Open another terminal window to run following tutorial ...

server/.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
/dsps.zip
2-
31
/coverage*
42
/pprof
53

64
# Temporary file in Makefile
75
/go.mod.bak
6+
7+
dist/
8+
CREDITS

server/.goreleaser.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
before:
2+
hooks:
3+
- go install github.com/golang/mock/mockgen@latest
4+
- go install github.com/Songmu/gocredits/cmd/gocredits@latest
5+
- go generate ./...
6+
- go mod tidy
7+
- gocredits -w -skip-missing .
8+
builds:
9+
- env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
- windows
14+
- darwin
15+
archives:
16+
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
17+
replacements:
18+
darwin: Darwin
19+
linux: Linux
20+
windows: Windows
21+
386: i386
22+
amd64: x86_64
23+
files:
24+
- CHANGELOG*
25+
- CREDITS
26+
- README*
27+
checksum:
28+
name_template: 'checksums.txt'
29+
snapshot:
30+
name_template: "{{ incpatch .Version }}-next"
31+
changelog:
32+
sort: asc
33+
filters:
34+
exclude:
35+
- '^docs:'
36+
- '^test:'
37+
release:
38+
prerelease: true

server/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ARG DSPS_VERSION_ID=""
33
WORKDIR /go/src/github.com/dsps/server
44
COPY . .
55
RUN go install && go install github.com/Songmu/gocredits/cmd/gocredits
6-
RUN make dsps/dsps-$(uname -o | sed 's/GNU\///')-$(uname -m) && mv dsps/dsps-$(uname -o | sed 's/GNU\///')-$(uname -m) /dsps.bin
6+
RUN make dist/dsps-$(uname -o | sed 's/GNU\///')-$(uname -m) && mv dist/dsps-$(uname -o | sed 's/GNU\///')-$(uname -m) /dsps.bin
77

88
FROM alpine:3.12.3
99
# Add some utilities for convinience: gettext (contains envsubst), curl, jq

server/Makefile

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
SHELL := /bin/bash
22

3-
release_dir = dsps
3+
release_dir = dist
44
go_module_files = go.mod go.sum
55
go_src_files = $(shell find . -type f -name '*.go')
66
build_deps = $(go_module_files) $(go_src_files) | $(release_dir)
77

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

11-
.PHONY: build test test.profile lint generate
12-
13-
build: $(release_dir).zip
11+
.PHONY: test test.profile lint generate
1412

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

39-
$(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
40-
zip -r $@ $(release_dir)/ -x '$(release_dir)/.gitignore'
41-
4237
$(release_dir):
43-
mkdir $(release_dir)
44-
45-
$(release_dir)/CREDITS: $(go_module_files) | $(release_dir)
46-
go install github.com/Songmu/gocredits/cmd/gocredits
47-
rm -f $@
48-
gocredits -skip-missing . > $@
38+
mkdir -p $(release_dir)
4939

5040
$(release_dir)/dsps-Linux-x86_64: $(build_deps)
5141
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ -ldflags "-X main.BuildDist=linux-amd64" -ldflags $(ldflags) main.go

server/config/admin_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/google/uuid"
1010
"golang.org/x/xerrors"
1111

12-
"github.com/saiya/dsps/server/domain"
12+
"github.com/m3dev/dsps/server/domain"
1313
)
1414

1515
// AdminConfig represents administration feature settings

server/config/admin_config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77

88
"github.com/stretchr/testify/assert"
99

10-
. "github.com/saiya/dsps/server/config"
11-
"github.com/saiya/dsps/server/domain"
10+
. "github.com/m3dev/dsps/server/config"
11+
"github.com/m3dev/dsps/server/domain"
1212
)
1313

1414
func TestAdminDefaultConfig(t *testing.T) {

0 commit comments

Comments
 (0)