-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (90 loc) · 3.57 KB
/
exporter-build.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
name: "Ethminer Metrics Exporter"
on:
pull_request:
branches:
- '**'
paths:
- 'ethminer-exporter/*'
- 'ethminer-exporter/**/*'
- .github/workflows/exporter-build.yml
push:
branches:
- main
paths:
- 'ethminer-exporter/*'
- 'ethminer-exporter/**/*'
- .github/workflows/exporter-build.yml
jobs:
ci:
runs-on: ubuntu-18.04
name: CI
steps:
- name: git checkout
uses: actions/checkout@v2
- name: extract versions
id: versions
run: |
version=$(cat VERSION)
echo "::set-output name=git-tag::ethminer-exporter-v${version}"
echo "::set-output name=version::v${version}"
echo "::set-output name=dirty-version::v${version}-$(git rev-parse --short HEAD)"
working-directory: ethminer-exporter
- name: docker login
uses: azure/docker-login@v1
with:
login-server: ghcr.io
username: hfuss
password: ${{ secrets.PACKAGES_TOKEN }}
- name: test
run: |
make test
fmt=$(go fmt ./.../ | wc -l)
[[ "$fmt" -eq "0" ]]
working-directory: ethminer-exporter
- name: build
run: |
docker build . -f build/Dockerfile -t ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.dirty-version }}
docker run -i ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.dirty-version }} client --help
docker push ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.dirty-version }}
working-directory: ethminer-exporter
- name: enforce new version
run: |
git ls-remote --exit-code origin --tags '${{ steps.versions.outputs.git-tag }}' && found=true
if [[ "${found}" == "true" ]]; then
echo "${{ steps.versions.outputs.git-tag }} tag already exists, please update the version and changelog"
exit 1
fi
- name: enforce changelog
if: ${{ github.event_name == 'pull_request' }}
uses: dangoslen/changelog-enforcer@v2
with:
changeLogPath: 'ethminer-exporter/CHANGELOG.md'
skipLabels: 'Skip-Changelog'
expectedLatestVersion: ${{ steps.versions.outputs.version }}
- name: extract changelog
id: changelog
uses: mindsers/changelog-reader-action@v2
with:
validation_depth: 10
version: ${{ steps.versions.outputs.version }}
path: ethminer-exporter/CHANGELOG.md
- name: tag images
run: |
docker tag ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.dirty-version }} ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.version }}
docker tag ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.dirty-version }} ghcr.io/hfuss/ethminer-exporter:latest
- name: promote images
if: ${{ github.event_name == 'push' }}
run: |
docker push ghcr.io/hfuss/ethminer-exporter:${{ steps.versions.outputs.version }}
docker push ghcr.io/hfuss/ethminer-exporter:latest
- name: git release
uses: actions/create-release@v1
if: ${{ github.event_name == 'push' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.versions.outputs.git-tag }}
release_name: Ethminer Metrics Exporter ${{ steps.versions.outputs.version }} Release
body: ${{ steps.changelog.outputs.changes }}
draft: false
prerelease: false