-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (101 loc) · 3.09 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: build
on:
push:
branches:
- main
- "feature/**"
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
- name: setup go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: test
run: |
export GOTESTSUM_VERSION=1.12.0
curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz | sudo tar -C /usr/local/bin -xz
gotestsum --format short-verbose --no-summary=skipped ./...
- name: build
uses: goreleaser/goreleaser-action@master
with:
version: latest
args: --skip=publish,validate --clean --snapshot
- name: prepare dist directory
run: |
find ./dist/ -not -name '*.tar.gz' -not -name '*.zip' -not -name 'dist' -not -wholename './dist/grpc-ditto_linux_amd*' -not -name 'pkg' -delete
cp Dockerfile dist/
- name: store artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: |
dist
release:
name: release
outputs:
release_url: ${{ steps.create_release.outputs.upload_url }}
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: download artifacts
uses: actions/download-artifact@v3
with:
name: dist
- name: prep
id: prep
run: |
find . -name "grpc-ditto*" -type f -exec chmod +x {} \;
echo ::set-output name=tags::${GITHUB_REF#refs/tags/v}
- name: create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
v${{ steps.prep.outputs.tags }}
draft: false
prerelease: true
- name: set up docker buildx
uses: docker/setup-buildx-action@v2
- name: login to github container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build and push
uses: docker/build-push-action@v3
with:
context: grpc-ditto_linux_amd64_v1
file: ./Dockerfile
push: true
tags: |
ghcr.io/vadimi/grpc-ditto:latest
ghcr.io/vadimi/grpc-ditto:${{ steps.prep.outputs.tags }}
upload-artifacts:
name: upload-artifacts
needs: release
runs-on: ubuntu-latest
steps:
- name: download artifacts
uses: actions/download-artifact@v2
with:
name: dist
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: pkg/grpc-ditto*
tag: ${{ github.ref }}
overwrite: true
file_glob: true