Skip to content

Commit fef27ca

Browse files
committed
ci: setup ci/cd
1 parent 2fae579 commit fef27ca

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
tags:
9+
- "v*"
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version-file: go.mod
26+
cache: true
27+
28+
- name: Download modules
29+
run: go mod download
30+
31+
- name: Run tests
32+
run: go test ./...
33+
34+
release:
35+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
36+
needs: test
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
42+
- name: Set up Go
43+
uses: actions/setup-go@v5
44+
with:
45+
go-version-file: go.mod
46+
cache: true
47+
48+
- name: Download modules
49+
run: go mod download
50+
51+
- name: Test
52+
run: go test ./...
53+
54+
- name: Build
55+
run: go build ./...
56+
57+
- name: Bump tag and generate changelog
58+
id: bump
59+
uses: mathieudutour/github-tag-action@v6.2
60+
with:
61+
github_token: ${{ secrets.GITHUB_TOKEN }}
62+
release_branches: main
63+
default_bump: patch
64+
tag_prefix: v
65+
66+
- name: Publish release
67+
uses: softprops/action-gh-release@v1
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
with:
71+
tag_name: ${{ steps.bump.outputs.new_tag }}
72+
name: ${{ steps.bump.outputs.new_tag }}
73+
body: ${{ steps.bump.outputs.changelog }}

0 commit comments

Comments
 (0)