-
Notifications
You must be signed in to change notification settings - Fork 105
94 lines (86 loc) · 2.91 KB
/
test_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
name: Test build for PR
on:
pull_request:
types: [opened, synchronize]
paths-ignore:
- "README.md"
- "LICENSE"
- "docs/**"
- "**.sh"
- "**.md"
- ".github/workflows/dependabot_action.yml"
- ".github/workflows/pre-release.yml"
- ".github/workflows/test-build.yml"
- ".github/workflows/docker.yml"
- ".github/dependabot.yml"
- ".github/workflows/sync-wiki.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
init:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Comment Build started
run: |
gh pr comment "$PR_URL" -b "Build started for this PR. [Check logs](${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }})"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
needs: init
permissions:
contents: read
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows]
goarch: [amd64, arm64]
exclude:
- goos: windows
goarch: arm64
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: ./go.mod
- name: Build binary for ${{ matrix.goos }}/${{ matrix.goarch }}
run: |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ./bin/jiotv_go-${{ matrix.goos }}-${{ matrix.goarch }} -ldflags "-s -w" ./cmd/jiotv_go
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: jiotv_go-${{ matrix.goos }}-${{ matrix.goarch }}
path: ./bin/
post_success:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
needs: build
if: success()
steps:
- name: Comment Build success
run: |
gh pr comment "$PR_URL" --edit-last -b "Build success for this PR ✅. [Download artifacts](${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }})"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
post_failure:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
needs: build
if: failure()
steps:
- name: Comment Build failed
run: |
gh pr comment "$PR_URL" --edit-last -b "Build failed for this PR ❌. [Check logs](${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }})"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}