-
Notifications
You must be signed in to change notification settings - Fork 1
87 lines (74 loc) · 2.54 KB
/
ci.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
name: ci
on:
pull_request:
branches:
- main
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.run_number || github.event.pull_request.number }}
cancel-in-progress: true
jobs:
test:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set VERSION env
run: echo "VERSION=$(cat splitio/version.go | grep 'Version =' | awk '{print $4}' | tr -d '"')" >> $GITHUB_ENV
- name: Version validation
if: ${{ github.event_name == 'pull_request' }}
uses: mukunku/tag-exists-action@v1.6.0
id: checkTag
with:
tag: v${{ env.VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Fail workflow if tag exists
if: ${{ github.event_name == 'pull_request' && steps.checkTag.outputs.exists == 'true' }}
uses: actions/github-script@v7.0.1
with:
script: core.setFailed('[ERROR] Tag already exists.')
- name: Setup Go version
uses: actions/setup-go@v5
with:
go-version: '^1.20.7'
- name: Build binaries for host machine
run: make splitd splitcli
- name: Run tests
run: make test
- name: Cross build for GNU Linux & Darwin x amd64 & arm64
run: make binaries_release
- name: SonarQube Scan
uses: SonarSource/sonarcloud-github-action@v2.2.0
env:
SONAR_TOKEN: ${{ secrets.SONARQUBE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
projectBaseDir: .
args: >
-Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
-Dsonar.projectVersion=${{ env.VERSION }}
- name: Git tag
if: ${{ github.event_name == 'push' }}
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ env.VERSION }}
tag_prefix: 'v'
- name: Release
uses: softprops/action-gh-release@v2
if: ${{ github.event_name == 'push' }}
with:
name: splitd-${{ env.VERSION }}
tag_name: v${{ env.VERSION }}
files: |
splitd-darwin-amd64-${{ env.VERSION }}.bin
splitd-darwin-arm-${{ env.VERSION }}.bin
splitd-linux-amd64-${{ env.VERSION }}.bin
splitd-linux-amd64-fips-${{ env.VERSION }}.bin
splitd-linux-arm-${{ env.VERSION }}.bin