-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (114 loc) · 3.53 KB
/
release.yaml
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
name: Release application
on:
push:
branches:
- main
env:
VERSION: 0.1.2
jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Verify dependencies
run: go mod verify
- name: Build application
run: go build .
- name: Run unit tests
run: go test ./... -coverprofile=coverage.out
- name: Run vet
run: go vet .
- name: Install linter
run: go install golang.org/x/lint/golint@latest
- name: Run linter
run: golint ./...
checkVersion:
name: CheckVersion
runs-on: ubuntu-22.04
outputs:
versionCheck: ${{ steps.version.outputs.comparison-result }}
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Read version from Chart.yaml
id: read-version
uses: jbutcher5/read-yaml@main
with:
file: './charts/enphase-envoy-prometheus-exporter/Chart.yaml'
key-path: '["version"]'
- uses: madhead/semver-utils@latest
id: version
with:
version: ${{ env.VERSION }}
compare-to: ${{ steps.read-version.outputs.data }}
release:
name: Release
runs-on: ubuntu-22.04
needs: [ build, checkVersion ]
if: ${{ needs.checkVersion.outputs.versionCheck == '>' }}
steps:
- name: Check out code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup git config
run: |
git config user.name "Floris Feddema"
git config user.email "[email protected]"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Login docker registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/florisfeddema/enphase-envoy-prometheus-exporter:latest
ghcr.io/florisfeddema/enphase-envoy-prometheus-exporter:${{ env.VERSION }}
push: true
- name: Update version in Chart.yaml
uses: fjogeleit/yaml-update-action@main
with:
valueFile: 'charts/enphase-envoy-prometheus-exporter/Chart.yaml'
propertyPath: 'version'
value: ${{ env.VERSION }}
message: 'Update Image Version to ${{ env.VERSION }}'
commitChange: true
branch: main
- name: Release chart
uses: helm/[email protected]
with:
charts_dir: charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"