-
Notifications
You must be signed in to change notification settings - Fork 80
65 lines (55 loc) · 1.99 KB
/
release.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
name: Build and release
on:
# Runs automatically when a tag beginning with 'v' (i.e. a versioned release) is pushed.
push:
tags:
- v*
branches: [main]
pull_request:
branches: [main]
jobs:
build-release:
runs-on: ubuntu-20.04
permissions:
contents: read
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.21.4'
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: build binary
run: go build -ldflags "-X github.com/letsencrypt/unbound_exporter/util.BuildID=$(git rev-parse --short HEAD) -X github.com/letsencrypt/unbound_exporter/util.BuildBranch=$(git rev-parse --abbrev-ref HEAD) -X github.com/letsencrypt/unbound_exporter/util.BuildTime=$(date +%F-%T -u)"
- name: install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/[email protected]
- name: build deb
run: nfpm package -p deb -t unbound_exporter.deb
- name: upload deb
uses: actions/upload-artifact@v3
with:
name: unbound_exporter deb artifact
path: unbound_exporter.deb
push-release:
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: build-release
runs-on: ubuntu-20.04
# Overrides the org default of 'read'. This allows us to upload and post the
# resulting package file as part of a release.
permissions:
contents: write
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Download release artifact
uses: actions/download-artifact@v3
with:
name: unbound_exporter deb artifact
- name: rename
run: mv unbound_exporter.deb unbound_exporter-${GITHUB_REF_NAME}.x86_64.deb
- name: push release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://cli.github.com/manual/gh_release_create
run: gh release create "${GITHUB_REF_NAME}" unbound_exporter-${GITHUB_REF_NAME}.x86_64.deb