-
Notifications
You must be signed in to change notification settings - Fork 10
133 lines (115 loc) · 4.06 KB
/
build.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
name: Build Binaries
on:
push:
branches:
- main
tags:
- '**'
pull_request:
jobs:
build:
runs-on: ubuntu-latest
container: golang:1
strategy:
matrix:
GOOS: ["linux", "darwin", "windows"]
GOARCH: ["amd64", "arm64"]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build Binary
env:
GOOS: ${{ matrix.GOOS }}
GOARCH: ${{ matrix.GOARCH }}
run: make build
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: chia-exporter-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
path: ${{ github.workspace }}/bin/chia-exporter*
installers:
runs-on: ubuntu-latest
needs:
- build
strategy:
matrix:
GOOS: ["linux"]
GOARCH: ["amd64", "arm64"]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install fpm
run: sudo gem install fpm
- uses: actions/download-artifact@v3
with:
name: chia-exporter-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
path: artifacts
- name: Get tag name
if: startsWith(github.ref, 'refs/tags/')
id: tag-name
run: |
echo "TAG_NAME=$(echo ${{ github.ref }} | cut -d'/' -f 3)" >>$GITHUB_OUTPUT
- name: Generate .deb
run: |
chmod +x artifacts/chia-exporter
fpm \
--input-type dir \
--output-type deb \
--name chia-exporter \
--architecture ${{ matrix.GOARCH }} \
--version "${{ steps.tag-name.outputs.TAG_NAME || github.sha }}" \
--url "https://github.com/Chia-Network/chia-exporter" \
--maintainer "Chia Network Inc <[email protected]>" \
--description "Chia metrics Prometheus exporter" \
artifacts/chia-exporter=/usr/local/bin/chia-exporter [email protected]=/etc/systemd/system/[email protected]
mkdir -p installer-out
mv *.deb installer-out/
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: installer-chia-exporter-${{ matrix.GOOS }}-${{ matrix.GOARCH }}
path: ${{ github.workspace }}/installer-out/*.deb
release:
runs-on: ubuntu-latest
needs:
- installers
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
path: artifacts
- name: Show artifacts
run: tree artifacts
- name: Generate artifact zips
run: |
cd ${{ github.workspace }}/artifacts || exit 1
DIRS=$(find . -type d -name 'chia-exporter*')
while IFS= read -r dir; do
echo "Creating zip for $dir..."
zip -r $dir.zip $dir
done <<< "$DIRS"
- name: Get tag name
if: startsWith(github.ref, 'refs/tags/')
id: tag-name
run: |
TAG_NAME=$(echo ${{ github.ref }} | cut -d'/' -f 3)
echo "TAG_NAME=$TAG_NAME" >>$GITHUB_ENV
echo "TAG_NAME=$TAG_NAME" >>$GITHUB_OUTPUT
- name: Upload Release Artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
FILES=$(find ${{ github.workspace }}/artifacts -type f -name 'chia-exporter*.zip')
while IFS= read -r file; do
gh release upload \
$TAG_NAME \
$file
done <<< "$FILES"
gh release upload \
$TAG_NAME \
artifacts/installer-chia-exporter*/*.deb
- name: Trigger apt repo update
run: |
curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"release_version":"${{ steps.tag-name.outputs.TAG_NAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/chia-exporter/${{ github.sha }}/start
curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"release_version":"${{ steps.tag-name.outputs.TAG_NAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/chia-exporter/${{ github.sha }}/success/deploy