6
6
branches :
7
7
- master
8
8
pull_request :
9
+ workflow_dispatch :
9
10
release :
10
11
types :
11
12
- published
@@ -16,10 +17,7 @@ permissions:
16
17
packages : write
17
18
18
19
env :
19
- VERSION_PROMU : ' 0.14.0'
20
- VERSION_CONTAINERD : ' 1.7.21'
21
- VERSION_BUILDKIT : ' 0.15.2'
22
- VERSION_BUILDX : ' 0.16.2'
20
+ VERSION_PROMU : ' 0.17.0'
23
21
24
22
jobs :
25
23
build :
33
31
with :
34
32
go-version-file : ' go.mod'
35
33
36
- # https://github.com/pl4nty/Windows-Containers/blob/Main/helpful_tools/Install-BuildKit-GitHubActions/workflow.yaml
37
- - name : Setup containerd
38
- run : |
39
- curl.exe -L https://github.com/containerd/containerd/releases/download/v${{ env.VERSION_CONTAINERD }}/containerd-${{ env.VERSION_CONTAINERD }}-windows-amd64.tar.gz -o containerd.tar.gz
40
- tar.exe xvf containerd.tar.gz
41
- .\bin\containerd.exe --register-service
42
- Start-Service containerd
43
- - name : Setup BuildKit
44
- run : |
45
- curl.exe -L https://github.com/moby/buildkit/releases/download/v${{ env.VERSION_BUILDKIT }}/buildkit-v${{ env.VERSION_BUILDKIT }}.windows-amd64.tar.gz -o buildkit.tar.gz
46
- tar.exe xvf buildkit.tar.gz
47
-
48
- .\bin\buildkitd.exe --register-service
49
- Start-Service buildkitd
50
- - name : Setup Docker Buildx
51
- run : |
52
- curl.exe -L https://github.com/docker/buildx/releases/download/v${{ env.VERSION_BUILDX }}/buildx-v${{ env.VERSION_BUILDX }}.windows-amd64.exe -o $env:ProgramData\Docker\cli-plugins\docker-buildx.exe
53
- - uses : docker/setup-buildx-action@v3
54
- with :
55
- driver : remote
56
- endpoint : npipe:////./pipe/buildkitd
57
34
- name : Install WiX
58
35
run : dotnet tool install --global wix
59
36
@@ -114,16 +91,27 @@ jobs:
114
91
output\windows_exporter-*.exe
115
92
output\windows_exporter-*.msi
116
93
117
- - name : Build Docker Artifacts
118
- run : make build-all
94
+ - name : Release
95
+ if : startsWith(github.ref, 'refs/tags/')
119
96
env :
120
- VERSION : >-
121
- ${{
122
- startsWith(github.ref, 'refs/tags/') && 'latest' ||
123
- (
124
- github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || github.ref_name
125
- )
126
- }}
97
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
98
+ run : |
99
+ $TagName = $env:GITHUB_REF -replace 'refs/tags/', ''
100
+ Get-ChildItem -Path output\* -Include @('windows_exporter*.msi', 'windows_exporter*.exe', 'sha256sums.txt') | Foreach-Object {gh release upload $TagName $_}
101
+ docker :
102
+ name : Build docker images
103
+ runs-on : ubuntu-latest
104
+ needs :
105
+ - build
106
+ steps :
107
+ - uses : actions/checkout@v4
108
+ with :
109
+ fetch-depth : ' 0'
110
+
111
+ - name : Download Artifacts
112
+ uses : actions/download-artifact@v4
113
+ with :
114
+ name : windows_exporter_binaries
127
115
128
116
- name : Login to Docker Hub
129
117
if : ${{ github.event_name != 'pull_request' }}
@@ -132,13 +120,13 @@ jobs:
132
120
username : ${{ secrets.DOCKER_HUB_LOGIN }}
133
121
password : ${{ secrets.DOCKER_HUB_PASSWORD }}
134
122
135
- # - name: Login to quay.io
136
- # if: ${{ github.event_name != 'pull_request' }}
137
- # uses: docker/login-action@v3
138
- # with:
139
- # registry: quay.io
140
- # username: 'robot'
141
- # password: ${{ secrets.QUAY_IO_API_TOKEN }}
123
+ - name : Login to quay.io
124
+ if : ${{ github.event_name != 'pull_request' }}
125
+ uses : docker/login-action@v3
126
+ with :
127
+ registry : quay.io
128
+ username : ${{ secrets.QUAY_USER }}
129
+ password : ${{ secrets.QUAY_PASS }}
142
130
143
131
- name : Login to GitHub container registry
144
132
if : ${{ github.event_name != 'pull_request' }}
@@ -148,19 +136,32 @@ jobs:
148
136
username : ${{ github.repository_owner }}
149
137
password : ${{ secrets.GITHUB_TOKEN }}
150
138
151
- - name : Push Latest image
152
- if : ${{ github.event_name != 'pull_request' }}
153
- env :
154
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
155
- VERSION : ${{ startsWith(github.ref, 'refs/tags/') && 'latest' || github.ref_name }}
156
- run : |
157
- make push-all
158
-
159
- - name : Release
160
- if : startsWith(github.ref, 'refs/tags/')
161
- env :
162
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
163
- run : |
164
- $TagName = $env:GITHUB_REF -replace 'refs/tags/', ''
165
- Get-ChildItem -Path output\* -Include @('windows_exporter*.msi', 'windows_exporter*.exe', 'sha256sums.txt') | Foreach-Object {gh release upload $TagName $_}
166
- make push-all
139
+ - name : Docker meta
140
+ id : meta
141
+ uses : docker/metadata-action@v5
142
+ with :
143
+ images : |
144
+ ghcr.io/prometheus-community/windows-exporter
145
+ quay.io/prometheuscommunity/windows-exporter
146
+ docker.io/prometheuscommunity/windows-exporter
147
+ tags : |
148
+ type=semver,pattern={{version}}
149
+ type=ref,event=branch
150
+ type=ref,event=pr
151
+ labels : |
152
+ org.opencontainers.image.title=windows_exporter
153
+ org.opencontainers.image.description=A Prometheus exporter for Windows machines.
154
+ org.opencontainers.image.vendor=The Prometheus Community
155
+ org.opencontainers.image.licenses=MIT
156
+
157
+ - name : Set up Docker Buildx
158
+ uses : docker/setup-buildx-action@v3
159
+
160
+ - name : Build and push
161
+ uses : docker/build-push-action@v6
162
+ with :
163
+ context : .
164
+ push : ${{ github.event_name != 'pull_request' }}
165
+ tags : ${{ steps.meta.outputs.tags }}
166
+ labels : ${{ steps.meta.outputs.labels }}
167
+ platforms : windows/amd64
0 commit comments