Skip to content

Commit 044450d

Browse files
committed
Build packages for multiple architectures
1 parent 69d7852 commit 044450d

31 files changed

+219
-6340
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 98 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,84 @@ 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
28+
- name: Cache Go build
29+
uses: actions/cache@v3
30+
with:
31+
path: |
32+
~/.cache/go-build
33+
~/go/pkg/mod
34+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
35+
restore-keys: |
36+
${{ runner.os }}-go-build-
3537
- name: Setup Golang Environment
3638
uses: actions/setup-go@v3
3739
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
40+
go-version-file: go.mod
41+
- name: Determine GOPATH
42+
id: go
43+
run: echo "::set-output name=go_path::$(go env GOPATH)"
44+
- name: Build binary
45+
uses: goreleaser/goreleaser-action@v3
4346
with:
44-
path: ${{ github.workspace }}/nginx-asg-sync
45-
key: nginx-asg-sync-${{ github.run_id }}-${{ github.run_number }}
47+
version: latest
48+
args: build --snapshot --rm-dist --single-target
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
GOPATH: ${{ needs.checks.outputs.go_path }}
4652

4753
unit-tests:
4854
name: Unit Tests
4955
runs-on: ubuntu-20.04
5056
steps:
5157
- name: Checkout Repository
5258
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
5559
- name: Setup Golang Environment
5660
uses: actions/setup-go@v3
5761
with:
58-
go-version: ${{ env.GO_VERSION }}
62+
go-version-file: go.mod
5963
- name: Run Tests
6064
run: make test
6165

6266
build:
63-
name: Build Image
67+
name: Build Packages
6468
runs-on: ubuntu-20.04
6569
needs: [binary, unit-tests]
6670
steps:
6771
- name: Checkout Repository
6872
uses: actions/checkout@v3
69-
- name: Fetch Cached Artifacts
70-
uses: actions/cache@v3
7173
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
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
74+
fetch-depth: 0
75+
- name: Cache Go build
76+
uses: actions/cache@v3
12977
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
78+
path: |
79+
~/.cache/go-build
80+
~/go/pkg/mod
81+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
82+
restore-keys: |
83+
${{ runner.os }}-go-build-
84+
- name: Setup Golang Environment
85+
uses: actions/setup-go@v3
13586
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
87+
go-version-file: go.mod
88+
- name: Determine GOPATH
89+
id: go
90+
run: echo "::set-output name=go_path::$(go env GOPATH)"
91+
- name: Download Syft
92+
uses: anchore/sbom-action/download-syft@v0.11.0
93+
- name: Build binaries
94+
uses: goreleaser/goreleaser-action@v3
14795
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
96+
version: latest
97+
args: release ${{ startsWith(github.ref, 'refs/tags/') && '' || '--snapshot' }} --rm-dist
98+
env:
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
GOPATH: ${{ needs.checks.outputs.go_path }}

.github/workflows/lint.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ 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
3431
- name: Lint Code
3532
uses: golangci/golangci-lint-action@v3

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