Skip to content

Commit c7d7d1c

Browse files
author
Josh Newman
committed
feat: add release workflow
1 parent 9fbefae commit c7d7d1c

File tree

2 files changed

+94
-11
lines changed

2 files changed

+94
-11
lines changed

.github/workflows/lint.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
name: Lint
2+
13
on:
2-
workflow_call:
3-
inputs:
4-
lint_proto:
5-
type: boolean
6-
default: false
7-
lint_go:
8-
type: boolean
9-
default: false
4+
workflow_call: { }
5+
push:
6+
branches:
7+
- main
108

119
jobs:
1210
lint_proto:
@@ -20,20 +18,19 @@ jobs:
2018
input: api
2119
- uses: bufbuild/buf-breaking-action@v1
2220
with:
23-
against: "https://github.com/${GITHUB_REPOSITORY}.git#branch=main,ref=HEAD~1"
21+
input: api
22+
against: 'https://github.com/${GITHUB_REPOSITORY}.git#branch=main,ref=HEAD~1'
2423

2524
lint_go:
2625
name: Lint Go
2726
runs-on: ubuntu-latest
2827
steps:
2928
- uses: actions/checkout@v3
3029
- uses: actions/setup-go@v3
31-
if: ${{ inputs.lint_go }}
3230
with:
3331
go-version: 1.19
3432
check-latest: true
3533
cache: true
3634
- uses: golangci/golangci-lint-action@v3
37-
if: ${{ inputs.lint_go }}
3835
with:
3936
version: v1.50.1

.github/workflows/release.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
type:
7+
description: The type of release.
8+
type: choice
9+
options:
10+
- proto
11+
- generator
12+
- all
13+
version_type:
14+
description: The version type to bump.
15+
type: choice
16+
options:
17+
- patch
18+
- minor
19+
- major
20+
default: minor
21+
22+
jobs:
23+
lint:
24+
uses: ./github/workflows/lint.yaml
25+
26+
release_proto:
27+
name: Release Proto
28+
runs-on: ubuntu-latest
29+
if: ${{ inputs.type == 'proto' || inputs.type == 'all' }}
30+
needs:
31+
- lint
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v3
35+
- name: Buf Setup
36+
uses: bufbuild/buf-setup-action@v1
37+
- name: Push Proto
38+
uses: bufbuild/buf-push-action@v1
39+
with:
40+
input: api
41+
buf_token: ${{ secrets.BUF_TOKEN }}
42+
43+
release_generator:
44+
name: Release Generator
45+
runs-on: ubuntu-latest
46+
if: ${{ intputs.type == 'generator' || inputs.type == 'all' }}
47+
needs:
48+
- lint
49+
steps:
50+
- name: Checkout
51+
uses: actions/checkout@v3
52+
with:
53+
fetch-depth: 0
54+
- name: Go Setup
55+
uses: actions/setup-go@v3
56+
with:
57+
go-version: 1.19
58+
check-latest: true
59+
cache: true
60+
- name: Go Mod Download
61+
run: go mod download
62+
- name: Get version
63+
id: get_version
64+
run: |
65+
version=$(git describe --abbrev=0 --match "v*.*.*" || echo "v0.1.0")
66+
echo ::set-output name=version::$version
67+
- name: Next Version
68+
uses: technicallyjosh/next-version-action@v1
69+
id: version
70+
with:
71+
version: ${{ steps.get_version.outputs.version }}
72+
type: minor
73+
- name: Tag
74+
uses: rickstaa/action-create-tag@v1
75+
with:
76+
tag: ${{ steps.version.outputs.next_version }}
77+
- uses: goreleaser/goreleaser-action@v4
78+
with:
79+
distribution: goreleaser
80+
version: latest
81+
args: release --rm-dist
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
- name: Rollback
85+
if: failure()
86+
run: git push --delete origin ${{ steps.version.outputs.version_tag }}

0 commit comments

Comments
 (0)