This repository has been archived by the owner on Nov 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
173 lines (170 loc) · 5.1 KB
/
ci.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: CI
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.18'
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/go/pkg/sumdb
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Check
run: make check
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.18'
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/go/pkg/sumdb
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
run: make
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.18'
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/go/pkg/sumdb
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test
run: make test
release:
needs:
- lint
- build
- test
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
- name: Get tag version
id: get-tag-version
uses: actions/github-script@v6
with:
result-encoding: string
script: |
return context.ref.replace(/^refs\/tags\/v/, '');
- uses: mindsers/changelog-reader-action@v2
id: read-changelog
with:
version: ${{ steps.get-tag-version.outputs.result }}
- uses: actions/create-release@v1
id: create-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: v${{ steps.read-changelog.outputs.version }}
body: ${{ steps.read-changelog.outputs.changes }}
prerelease: ${{ steps.read-changelog.outputs.status == 'prereleased' }}
draft: ${{ steps.read-changelog.outputs.status == 'unreleased' }}
outputs:
upload-url: ${{ steps.create-release.outputs.upload_url }}
release-assets:
needs: release
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: darwin
arch: amd64
- os: windows
arch: amd64
- os: windows
arch: '386'
- os: linux
arch: amd64
- os: linux
arch: '386'
- os: linux
arch: arm64
- os: linux
arch: arm
- os: freebsd
arch: amd64
- os: freebsd
arch: '386'
- os: freebsd
arch: arm
- os: netbsd
arch: amd64
- os: netbsd
arch: '386'
- os: openbsd
arch: amd64
- os: openbsd
arch: '386'
- os: solaris
arch: amd64
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.18'
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/go/pkg/sumdb
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
env:
PLUGIN_DIST_OS: ${{ matrix.os }}
PLUGIN_DIST_ARCH: ${{ matrix.arch }}
run: |
make "dist-bin-${PLUGIN_DIST_OS}-${PLUGIN_DIST_ARCH}"
- name: Get asset information
id: get-asset-information
run: |
archive_name="$( find ./artifacts/ -type f -not -name '*.sha256.asc' -printf '%f\n' )"
archive_media_type="$( file -b --mime-type "./artifacts/${archive_name}" )"
checksum_name="${archive_name}.sha256.asc"
checksum_media_type="$( file -b --mime-type "./artifacts/${checksum_name}" )"
echo "archive-name=${archive_name}" >>"$GITHUB_OUTPUT"
echo "archive-media-type=${archive_media_type}" >>"$GITHUB_OUTPUT"
echo "checksum-name=${checksum_name}" >>"$GITHUB_OUTPUT"
echo "checksum-media-type=${checksum_media_type}" >>"$GITHUB_OUTPUT"
- name: Upload checksum asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload-url }}
asset_path: ./artifacts/${{ steps.get-asset-information.outputs.checksum-name }}
asset_name: ${{ steps.get-asset-information.outputs.checksum-name }}
asset_content_type: ${{ steps.get-asset-information.outputs.checksum-media-type }}
- name: Upload archive asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload-url }}
asset_path: ./artifacts/${{ steps.get-asset-information.outputs.archive-name }}
asset_name: ${{ steps.get-asset-information.outputs.archive-name }}
asset_content_type: ${{ steps.get-asset-information.outputs.archive-media-type }}