forked from prometheus-community/postgres_exporter
-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (78 loc) · 2.34 KB
/
ci.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
name: CI
on:
push:
branches:
- master
tags:
- "v*.*.*"
pull_request:
jobs:
calculate-tag:
uses: ./.github/workflows/calculate-tag.yaml
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Test
run: make test
build:
runs-on: ubuntu-latest
needs: [ calculate-tag, test ]
steps:
- name: Checkout Code
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build
run: make crossbuild
- name: Set version
run: echo "${{ needs.calculate-tag.outputs.tag }}" | sed s/v//g > VERSION
- name: Package
run: make crossbuild-tarballs
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: tarballs
path: ./.tarballs/*.tar.gz
commit-message:
runs-on: ubuntu-latest
outputs:
head-commit-message: ${{ steps.get_head_commit_message.outputs.headCommitMsg }}
steps:
- name: Checkout code
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
with:
fetch-depth: 0
ref: ${{github.event.after}}
- name: Print head git commit message
id: get_head_commit_message
run: |
msg="$(git show -s --format=%s)"
echo "Latest msg is $msg"
echo "headCommitMsg=$msg" >> $GITHUB_OUTPUT
publish:
runs-on: ubuntu-latest
needs: [ calculate-tag, build, commit-message ]
permissions: write-all
if: contains(needs.commit-message.outputs.head-commit-message, 'pre-release') || startsWith(github.ref, 'refs/tags')
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: tarballs
- name: Create GH release
uses: softprops/action-gh-release@v1
id: release
with:
generate_release_notes: true
tag_name: ${{ needs.calculate-tag.outputs.tag }}
prerelease: "${{ github.event_name == 'pull_request' }}"
files: |
*.tar.gz