Skip to content

Commit 16bc280

Browse files
authored
Build packages for multiple architectures (#267)
Adds support for multiple architectures and simplifies build process. Closes #223
1 parent 69d7852 commit 16bc280

32 files changed

+214
-6342
lines changed

.github/workflows/ci.yml

Lines changed: 41 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
name: Continuous Integration
1+
name: CI
22

33
on:
44
push:
55
branches:
66
- main
77
paths-ignore:
88
- '**.md'
9+
tags:
10+
- 'v[0-9]+.[0-9]+.[0-9]+'
911
pull_request:
1012
branches:
1113
- main
@@ -15,136 +17,76 @@ on:
1517
- synchronize
1618
paths-ignore:
1719
- '**.md'
18-
create:
19-
tags:
20-
- 'v[0-9]+.[0-9]+.[0-9]+*'
21-
22-
env:
23-
DOCKER_BUILDKIT: 1
2420

2521
jobs:
26-
2722
binary:
2823
name: Build Binary
2924
runs-on: ubuntu-20.04
3025
steps:
3126
- name: Checkout Repository
3227
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
3528
- name: Setup Golang Environment
3629
uses: actions/setup-go@v3
3730
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
4338
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 }}
4644

4745
unit-tests:
4846
name: Unit Tests
4947
runs-on: ubuntu-20.04
5048
steps:
5149
- name: Checkout Repository
5250
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
5551
- name: Setup Golang Environment
5652
uses: actions/setup-go@v3
5753
with:
58-
go-version: ${{ env.GO_VERSION }}
54+
go-version-file: go.mod
55+
cache: true
5956
- name: Run Tests
6057
run: make test
6158

6259
build:
63-
name: Build Image
60+
name: Build Packages
6461
runs-on: ubuntu-20.04
6562
needs: [binary, unit-tests]
6663
steps:
6764
- name: Checkout Repository
6865
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
9166
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
12970
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
13578
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/download-syft@v0.12.0
85+
- name: Build binaries
86+
uses: goreleaser/goreleaser-action@v3
14787
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 }}

.github/workflows/lint.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ jobs:
2424
steps:
2525
- name: Checkout Repository
2626
uses: actions/checkout@v3
27-
- name: Output Variables
28-
id: vars
29-
run: echo "::set-output name=go_version::$(grep "go 1." go.mod | cut -d " " -f 2)"
3027
- name: Setup Golang Environment
3128
uses: actions/setup-go@v3
3229
with:
33-
go-version: ${{ steps.vars.outputs.go_version }}
30+
go-version-file: go.mod
31+
cache: true
3432
- name: Lint Code
3533
uses: golangci/golangci-lint-action@v3

.github/workflows/notifications.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_run:
55
branches: main
66
workflows:
7-
- "Continuous Integration"
7+
- "CI"
88
- "CodeQL"
99
- "Fossa"
1010
- "Lint"

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1-
/build_output
21
.DS_Store
2+
3+
# binaries
34
nginx-asg-sync
5+
/build_output
6+
dist
7+
8+
# IDEs
9+
.vscode
10+
.idea

.goreleaser.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
env:
2+
- CGO_ENABLED=0
3+
4+
before:
5+
hooks:
6+
- make LICENSES
7+
8+
builds:
9+
- id: nginx-asg-sync
10+
goos:
11+
- linux
12+
goarch:
13+
- 386
14+
- amd64
15+
- arm64
16+
- s390x
17+
flags:
18+
- -trimpath
19+
gcflags:
20+
- all=-trimpath={{.Env.GOPATH}}
21+
asmflags:
22+
- all=-trimpath={{.Env.GOPATH}}
23+
main: ./cmd/sync
24+
binary: nginx-asg-sync
25+
26+
archives:
27+
- files:
28+
- README.md
29+
- LICENSE
30+
- CHANGELOG.md
31+
- build/config.yaml.example
32+
33+
sboms:
34+
- artifacts: archive
35+
36+
changelog:
37+
skip: true
38+
39+
nfpms:
40+
- file_name_template: "{{ .ConventionalFileName }}"
41+
vendor: NGINX Inc.
42+
homepage: https://github.com/nginxinc/nginx-asg-sync
43+
maintainer: NGINX Inc. <integrations@nginx.com>
44+
description: |-
45+
NGINX Plus Integration with Cloud Autoscaling.
46+
This package contains software that integrates NGINX Plus
47+
with AWS Auto Scaling groups and Azure Virtual Machine Scale Set
48+
license: BSD-2-Clause
49+
dependencies:
50+
- nginx-plus
51+
- systemd
52+
suggests:
53+
- logrotate
54+
formats:
55+
- deb
56+
- rpm
57+
release: 1
58+
section: utils
59+
priority: optional
60+
bindir: /usr/sbin
61+
contents:
62+
- src: build/config.yaml.example
63+
dst: /etc/nginx/config.yaml.example
64+
type: "config|noreplace"
65+
- src: build/logrotate
66+
dst: /etc/logrotate.d/nginx-asg-sync
67+
type: "config|noreplace"
68+
- dst: /var/log/nginx-asg-sync
69+
type: dir
70+
- src: build/nginx-asg-sync.service
71+
dst: /lib/systemd/system/nginx-asg-sync.service
72+
- src: LICENSE
73+
dst: /usr/share/doc/nginx-asg-sync/copyright
74+
packager: deb
75+
- src: LICENSES
76+
dst: /usr/share/doc/nginx-asg-sync/LICENSES
77+
packager: deb
78+
- src: LICENSE
79+
dst: /usr/share/licenses/nginx-asg-sync/LICENSE
80+
packager: rpm
81+
- src: LICENSES
82+
dst: /usr/share/licenses/nginx-asg-sync/LICENSES
83+
packager: rpm
84+
- src: README.md
85+
dst: /usr/share/doc/nginx-asg-sync/README
86+
type: doc
87+
overrides:
88+
rpm:
89+
scripts:
90+
postinstall: "build/postinstall.sh"
91+
preremove: "build/preremove.sh"
92+
postremove: "build/postremove.sh"

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ further defined and clarified by project maintainers.
5757
## Enforcement
5858

5959
Instances of abusive, harassing, or otherwise unacceptable behavior may be
60-
reported by contacting the project team at [mailto:nginx@nginx.org]. All
60+
reported by contacting the project team at integrations@nginx.com. All
6161
complaints will be reviewed and investigated and will result in a response that
6262
is deemed necessary and appropriate to the circumstances. The project team is
6363
obligated to maintain confidentiality with regard to the reporter of an incident.

LICENSES

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
github.com/Azure/azure-sdk-for-go,https://github.com/Azure/azure-sdk-for-go/blob/v66.0.0/LICENSE.txt,MIT
2+
github.com/Azure/go-autorest/autorest,https://github.com/Azure/go-autorest/blob/autorest/v0.11.24/autorest/LICENSE,Apache-2.0
3+
github.com/Azure/go-autorest/autorest/adal,https://github.com/Azure/go-autorest/blob/autorest/adal/v0.9.18/autorest/adal/LICENSE,Apache-2.0
4+
github.com/Azure/go-autorest/autorest/azure/auth,https://github.com/Azure/go-autorest/blob/autorest/azure/auth/v0.5.11/autorest/azure/auth/LICENSE,Apache-2.0
5+
github.com/Azure/go-autorest/autorest/azure/cli,https://github.com/Azure/go-autorest/blob/autorest/azure/cli/v0.4.5/autorest/azure/cli/LICENSE,Apache-2.0
6+
github.com/Azure/go-autorest/autorest/date,https://github.com/Azure/go-autorest/blob/autorest/date/v0.3.0/autorest/date/LICENSE,Apache-2.0
7+
github.com/Azure/go-autorest/autorest/to,https://github.com/Azure/go-autorest/blob/autorest/to/v0.4.0/autorest/to/LICENSE,Apache-2.0
8+
github.com/Azure/go-autorest/autorest/validation,https://github.com/Azure/go-autorest/blob/autorest/validation/v0.3.1/autorest/validation/LICENSE,Apache-2.0
9+
github.com/Azure/go-autorest/logger,https://github.com/Azure/go-autorest/blob/logger/v0.2.1/logger/LICENSE,Apache-2.0
10+
github.com/Azure/go-autorest/tracing,https://github.com/Azure/go-autorest/blob/tracing/v0.6.0/tracing/LICENSE,Apache-2.0
11+
github.com/aws/aws-sdk-go,https://github.com/aws/aws-sdk-go/blob/v1.44.4/LICENSE.txt,Apache-2.0
12+
github.com/aws/aws-sdk-go/internal/sync/singleflight,https://github.com/aws/aws-sdk-go/blob/v1.44.4/internal/sync/singleflight/LICENSE,BSD-3-Clause
13+
github.com/dimchansky/utfbom,https://github.com/dimchansky/utfbom/blob/v1.1.1/LICENSE,Apache-2.0
14+
github.com/golang-jwt/jwt/v4,https://github.com/golang-jwt/jwt/blob/v4.2.0/LICENSE,MIT
15+
github.com/jmespath/go-jmespath,https://github.com/jmespath/go-jmespath/blob/v0.4.0/LICENSE,Apache-2.0
16+
github.com/mitchellh/go-homedir,https://github.com/mitchellh/go-homedir/blob/v1.1.0/LICENSE,MIT
17+
github.com/nginxinc/nginx-asg-sync/cmd/sync,https://github.com/nginxinc/nginx-asg-sync/blob/HEAD/LICENSE,BSD-2-Clause
18+
github.com/nginxinc/nginx-plus-go-client/client,https://github.com/nginxinc/nginx-plus-go-client/blob/v0.10.0/LICENSE,Apache-2.0
19+
golang.org/x/crypto/pkcs12,https://cs.opensource.google/go/x/crypto/+/e495a2d5:LICENSE,BSD-3-Clause
20+
gopkg.in/yaml.v2,https://github.com/go-yaml/yaml/blob/v2.4.0/LICENSE,Apache-2.0

0 commit comments

Comments
 (0)