Skip to content

Commit 809eafb

Browse files
committed
Build packages for multiple architectures
1 parent 90c9f48 commit 809eafb

30 files changed

+229
-6335
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
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,96 @@ 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:
22+
vars:
23+
name: Checks and variables
24+
runs-on: ubuntu-20.04
25+
outputs:
26+
go_version: ${{ steps.vars.outputs.go_version }}
27+
steps:
28+
- name: Checkout Repository
29+
uses: actions/checkout@v3
30+
- name: Output Variables
31+
id: vars
32+
run: |
33+
echo "::set-output name=go_version::$(grep "go 1." go.mod | cut -d " " -f 2)"
2634
2735
binary:
2836
name: Build Binary
2937
runs-on: ubuntu-20.04
38+
needs: vars
3039
steps:
3140
- name: Checkout Repository
3241
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
42+
- name: Cache Go build
43+
uses: actions/cache@v3
44+
with:
45+
path: |
46+
~/.cache/go-build
47+
~/go/pkg/mod
48+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
49+
restore-keys: |
50+
${{ runner.os }}-go-build-
3551
- name: Setup Golang Environment
3652
uses: actions/setup-go@v3
3753
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
54+
go-version: ${{ needs.checks.outputs.go_version }}
55+
- name: Build binary
56+
uses: goreleaser/goreleaser-action@v3
4357
with:
44-
path: ${{ github.workspace }}/nginx-asg-sync
45-
key: nginx-asg-sync-${{ github.run_id }}-${{ github.run_number }}
58+
version: latest
59+
args: build --snapshot --rm-dist --single-target
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
GOPATH: ${{ needs.checks.outputs.go_path }}
4663

4764
unit-tests:
4865
name: Unit Tests
4966
runs-on: ubuntu-20.04
67+
needs: vars
5068
steps:
5169
- name: Checkout Repository
5270
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
5571
- name: Setup Golang Environment
5672
uses: actions/setup-go@v3
5773
with:
58-
go-version: ${{ env.GO_VERSION }}
74+
go-version: ${{ needs.vars.outputs.go_version }}
5975
- name: Run Tests
6076
run: make test
6177

6278
build:
63-
name: Build Image
79+
name: Build Packages
6480
runs-on: ubuntu-20.04
6581
needs: [binary, unit-tests]
6682
steps:
6783
- name: Checkout Repository
6884
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-
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
11085
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
86+
fetch-depth: 0
87+
- name: Cache Go build
88+
uses: actions/cache@v3
12989
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
90+
path: |
91+
~/.cache/go-build
92+
~/go/pkg/mod
93+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
94+
restore-keys: |
95+
${{ runner.os }}-go-build-
96+
- name: Determine GOPATH
97+
id: go
98+
run: echo "::set-output name=go_path::$(go env GOPATH)"
99+
- name: Setup Golang Environment
100+
uses: actions/setup-go@v3
135101
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
102+
go-version: ${{ needs.vars.outputs.go_version }}
103+
- name: Download Syft
104+
uses: anchore/sbom-action/download-syft@v0.11.0
105+
- name: Build binaries
106+
uses: goreleaser/goreleaser-action@v3
147107
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
108+
version: latest
109+
args: release ${{ startsWith(github.ref, 'refs/tags/') && '' || '--snapshot' }} --rm-dist
110+
env:
111+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
GOPATH: ${{ needs.checks.outputs.go_path }}

.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)