|
1 |
| -name: Continuous Integration |
| 1 | +name: CI |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | push:
|
5 | 5 | branches:
|
6 | 6 | - main
|
7 | 7 | paths-ignore:
|
8 | 8 | - '**.md'
|
| 9 | + tags: |
| 10 | + - 'v[0-9]+.[0-9]+.[0-9]+' |
9 | 11 | pull_request:
|
10 | 12 | branches:
|
11 | 13 | - main
|
|
15 | 17 | - synchronize
|
16 | 18 | paths-ignore:
|
17 | 19 | - '**.md'
|
18 |
| - create: |
19 |
| - tags: |
20 |
| - - 'v[0-9]+.[0-9]+.[0-9]+*' |
21 |
| - |
22 |
| -env: |
23 |
| - DOCKER_BUILDKIT: 1 |
24 | 20 |
|
25 | 21 | jobs:
|
26 |
| - |
27 | 22 | binary:
|
28 | 23 | name: Build Binary
|
29 | 24 | runs-on: ubuntu-20.04
|
30 | 25 | steps:
|
31 | 26 | - name: Checkout Repository
|
32 | 27 | uses: actions/checkout@v3
|
33 |
| - - name: Determine Go version from go.mod |
34 |
| - run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV |
35 | 28 | - name: Setup Golang Environment
|
36 | 29 | uses: actions/setup-go@v3
|
37 | 30 | with:
|
38 |
| - go-version: ${{ env.GO_VERSION }} |
39 |
| - - name: Build Binary |
40 |
| - run: make build |
41 |
| - - name: Store Artifacts in Cache |
42 |
| - uses: actions/cache@v3 |
| 31 | + go-version-file: go.mod |
| 32 | + cache: true |
| 33 | + - name: Determine GOPATH |
| 34 | + id: go |
| 35 | + run: echo "::set-output name=go_path::$(go env GOPATH)" |
| 36 | + - name: Build binary |
| 37 | + uses: goreleaser/goreleaser-action@v3 |
43 | 38 | with:
|
44 |
| - path: ${{ github.workspace }}/nginx-asg-sync |
45 |
| - key: nginx-asg-sync-${{ github.run_id }}-${{ github.run_number }} |
| 39 | + version: latest |
| 40 | + args: build --snapshot --rm-dist --single-target |
| 41 | + env: |
| 42 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + GOPATH: ${{ steps.go.outputs.go_path }} |
46 | 44 |
|
47 | 45 | unit-tests:
|
48 | 46 | name: Unit Tests
|
49 | 47 | runs-on: ubuntu-20.04
|
50 | 48 | steps:
|
51 | 49 | - name: Checkout Repository
|
52 | 50 | uses: actions/checkout@v3
|
53 |
| - - name: Determine Go version from go.mod |
54 |
| - run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV |
55 | 51 | - name: Setup Golang Environment
|
56 | 52 | uses: actions/setup-go@v3
|
57 | 53 | with:
|
58 |
| - go-version: ${{ env.GO_VERSION }} |
| 54 | + go-version-file: go.mod |
| 55 | + cache: true |
59 | 56 | - name: Run Tests
|
60 | 57 | run: make test
|
61 | 58 |
|
62 | 59 | build:
|
63 |
| - name: Build Image |
| 60 | + name: Build Packages |
64 | 61 | runs-on: ubuntu-20.04
|
65 | 62 | needs: [binary, unit-tests]
|
66 | 63 | steps:
|
67 | 64 | - name: Checkout Repository
|
68 | 65 | uses: actions/checkout@v3
|
69 |
| - - name: Fetch Cached Artifacts |
70 |
| - uses: actions/cache@v3 |
71 |
| - with: |
72 |
| - path: ${{ github.workspace }}/nginx-asg-sync |
73 |
| - key: nginx-asg-sync-${{ github.run_id }}-${{ github.run_number }} |
74 |
| - - name: Docker Buildx |
75 |
| - uses: docker/setup-buildx-action@v2 |
76 |
| - - name: Build Image Amazon 2 |
77 |
| - uses: docker/build-push-action@v3 |
78 |
| - with: |
79 |
| - file: build/Dockerfile |
80 |
| - context: '.' |
81 |
| - target: local |
82 |
| - load: true |
83 |
| - cache-from: type=gha |
84 |
| - cache-to: type=gha,mode=max |
85 |
| - tags: amazon2-builder:${{ github.sha }} |
86 |
| - build-args: | |
87 |
| - CONTAINER_VERSION=amazonlinux:2 |
88 |
| - OS_TYPE=rpm_based |
89 |
| - - name: Run Amazon 2 |
90 |
| - uses: addnab/docker-run-action@v3 |
91 | 66 | with:
|
92 |
| - image: amazon2-builder:${{ github.sha }} |
93 |
| - run: /build.sh |
94 |
| - options: -v ${{ github.workspace }}/build/package/rpm:/rpm -v ${{ github.workspace }}/build_output:/build_output |
95 |
| - - name: Build Image Centos 7 |
96 |
| - uses: docker/build-push-action@v3 |
97 |
| - with: |
98 |
| - file: build/Dockerfile |
99 |
| - context: '.' |
100 |
| - target: local |
101 |
| - load: true |
102 |
| - cache-from: type=gha |
103 |
| - cache-to: type=gha,mode=max |
104 |
| - tags: centos7-builder:${{ github.sha }} |
105 |
| - build-args: | |
106 |
| - CONTAINER_VERSION=centos:7 |
107 |
| - OS_TYPE=rpm_based |
108 |
| - - name: Run Centos 7 |
109 |
| - uses: addnab/docker-run-action@v3 |
110 |
| - with: |
111 |
| - image: centos7-builder:${{ github.sha }} |
112 |
| - run: /build.sh |
113 |
| - options: -v ${{ github.workspace }}/build/package/rpm:/rpm -v ${{ github.workspace }}/build_output:/build_output |
114 |
| - - name: Build Image Centos stream 8 |
115 |
| - uses: docker/build-push-action@v3 |
116 |
| - with: |
117 |
| - file: build/Dockerfile |
118 |
| - context: '.' |
119 |
| - target: local |
120 |
| - load: true |
121 |
| - cache-from: type=gha |
122 |
| - cache-to: type=gha,mode=max |
123 |
| - tags: centosstream8-builder:${{ github.sha }} |
124 |
| - build-args: | |
125 |
| - CONTAINER_VERSION=quay.io/centos/centos:stream8 |
126 |
| - OS_TYPE=rpm_based |
127 |
| - - name: Run Centos stream 8 |
128 |
| - uses: addnab/docker-run-action@v3 |
| 67 | + fetch-depth: 0 |
| 68 | + - name: Setup Golang Environment |
| 69 | + uses: actions/setup-go@v3 |
129 | 70 | with:
|
130 |
| - image: centosstream8-builder:${{ github.sha }} |
131 |
| - run: /build.sh |
132 |
| - options: -v ${{ github.workspace }}/build/package/rpm:/rpm -v ${{ github.workspace }}/build_output:/build_output |
133 |
| - - name: Build Image Debian |
134 |
| - uses: docker/build-push-action@v3 |
| 71 | + go-version-file: go.mod |
| 72 | + cache: true |
| 73 | + - name: Determine GOPATH |
| 74 | + id: go |
| 75 | + run: echo "::set-output name=go_path::$(go env GOPATH)" |
| 76 | + - name: Publish Release Notes |
| 77 | + uses: release-drafter/release-drafter@v5 |
135 | 78 | with:
|
136 |
| - file: build/Dockerfile |
137 |
| - context: '.' |
138 |
| - target: local |
139 |
| - load: true |
140 |
| - cache-from: type=gha |
141 |
| - cache-to: type=gha,mode=max |
142 |
| - tags: debian-builder:${{ github.sha }} |
143 |
| - build-args: | |
144 |
| - OS_TYPE=deb_based |
145 |
| - - name: Run Debian |
146 |
| - uses: addnab/docker-run-action@v3 |
| 79 | + publish: true |
| 80 | + env: |
| 81 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 83 | + - name: Download Syft |
| 84 | + uses: anchore/sbom-action/[email protected] |
| 85 | + - name: Build binaries |
| 86 | + uses: goreleaser/goreleaser-action@v3 |
147 | 87 | with:
|
148 |
| - image: debian-builder:${{ github.sha }} |
149 |
| - run: /build.sh |
150 |
| - options: -v ${{ github.workspace }}/build/package/debian:/debian -v ${{ github.workspace }}/build_output:/build_output |
| 88 | + version: latest |
| 89 | + args: release ${{ startsWith(github.ref, 'refs/tags/') && '' || '--snapshot' }} --rm-dist |
| 90 | + env: |
| 91 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 92 | + GOPATH: ${{ steps.go.outputs.go_path }} |
0 commit comments