-
Notifications
You must be signed in to change notification settings - Fork 7
205 lines (174 loc) · 6.01 KB
/
release.yml
File metadata and controls
205 lines (174 loc) · 6.01 KB
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release'
required: true
type: string
permissions:
contents: write
packages: write
issues: write
pull-requests: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true
- name: Setup Protoc
uses: arduino/setup-protoc@v3
with:
version: '25.1'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Buf
uses: bufbuild/buf-setup-action@v1
with:
version: latest
- name: Install dependencies
run: |
go mod download
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
- name: Run tests
run: ./scripts/run_tests.sh
- name: Import GPG key
if: env.GPG_PRIVATE_KEY != ''
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
echo "$GPG_PRIVATE_KEY" | gpg --dearmor --output /tmp/keyring.gpg
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
- name: Upload release artifacts
uses: actions/upload-artifact@v7
with:
name: release-artifacts
path: dist/
docker:
name: Docker Images
runs-on: ubuntu-latest
needs: release
strategy:
matrix:
plugin:
- name: go-http
dockerfile: Dockerfile.http
- name: openapiv3
dockerfile: Dockerfile.openapi
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: |
${{ secrets.DOCKER_USERNAME }}/protoc-gen-${{ matrix.plugin.name }}
ghcr.io/${{ github.repository_owner }}/protoc-gen-${{ matrix.plugin.name }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
file: docker/${{ matrix.plugin.dockerfile }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
announce:
name: Announce Release
runs-on: ubuntu-latest
needs: [release, docker]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Get release info
id: release
run: |
TAG=${GITHUB_REF#refs/tags/}
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
- name: Create announcement issue
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tag = '${{ steps.release.outputs.tag }}';
const version = '${{ steps.release.outputs.version }}';
const { data: release } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag
});
const issueBody = `## 🎉 sebuf ${tag} has been released!
### What's New
${release.body}
### Installation
#### Using Go
\`\`\`bash
go install github.com/SebastienMelki/sebuf/cmd/protoc-gen-go-http@${tag}
go install github.com/SebastienMelki/sebuf/cmd/protoc-gen-openapiv3@${tag}
\`\`\`
#### Using Docker
\`\`\`bash
docker pull ghcr.io/sebastienmelki/protoc-gen-go-http:${version}
docker pull ghcr.io/sebastienmelki/protoc-gen-openapiv3:${version}
\`\`\`
#### Download Binaries
Download pre-built binaries from the [release page](${release.html_url}).
### Documentation
- [Getting Started](https://github.com/SebastienMelki/sebuf#quickstart)
- [API Documentation](https://pkg.go.dev/github.com/SebastienMelki/sebuf)
- [Examples](https://github.com/SebastienMelki/sebuf/tree/main/examples)
---
_This is an automated release announcement._`;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `🚀 Release ${tag}`,
body: issueBody,
labels: ['release', 'announcement']
});