-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (125 loc) · 3.68 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
name: CI
# Controls when the action will run. Triggers the workflow on push with tags
on:
push:
tags:
- '*'
pull_request:
permissions:
contents: write
# packages: write
# issues: write
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# The "build" workflow
build:
# The type of runner that the job will run on
strategy:
matrix:
go-version: [1.21, 1.22, 1.23]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Setup Go
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: true
# Run build of the application
- name: Run build
run: |
go env -w GOFLAGS=-mod=mod
go mod tidy
go build -v -o eoldate ./cmd/eoldate/main.go
golangci:
needs: build
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.22
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
# Optional: golangci-lint command line arguments.
args: --config ./.golangci-lint.yml
changelog:
needs: [build, golangci]
if: startsWith(github.ref, 'refs/tags/v')
name: Generate changelog
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@v3
id: git-cliff
with:
config: cliff.toml
args: -r . --latest
env:
OUTPUT: RELEASE_CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: copy release changelog
run: |
mkdir -p release_notes
cat RELEASE_CHANGELOG.md > release_notes/RELEASE_CHANGELOG.md
- name: upload release changelog
uses: actions/upload-artifact@master
with:
name: release-changelog
path: release_notes
# ================
# RELEASE JOB
# runs after a successful build
# only runs on push "*" tag
# ================
release:
needs: [build, golangci, changelog]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Setup Go
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22
cache: true
- name: Set GOPATH
run: |
echo "GOPATH=$(go env GOPATH)/bin" >> $GITHUB_ENV
- name: retrieve release changelog
uses: actions/download-artifact@master
with:
name: release-changelog
path: release_notes
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/v')
with:
distribution: goreleaser
version: latest
args: release --clean --release-notes release_notes/RELEASE_CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload assets
uses: actions/upload-artifact@v4
with:
name: eoldate
path: dist/*