Skip to content

Commit e6758c8

Browse files
committed
add assertion step to release-branch, sha checksum and build times
1 parent 654f84b commit e6758c8

File tree

3 files changed

+61
-49
lines changed

3 files changed

+61
-49
lines changed

.github/workflows/assertion.yml

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22
name: Generate and Sign Assertion Document
33

44
on:
5-
workflow_dispatch:
5+
workflow_call:
66
inputs:
7-
branch:
7+
packageVersion:
8+
required: true
9+
type: string
10+
arm64_sha:
11+
required: true
812
type: string
9-
description: "The branch to run the assertion workflow on"
10-
required: false
11-
default: main
13+
amd64_sha:
14+
required: true
15+
type: string
16+
secrets:
17+
ARTIFACTORY_USER:
18+
required: true
19+
ARTIFACTORY_TOKEN:
20+
required: true
1221

1322
jobs:
1423
build-assertion-document:
@@ -19,68 +28,48 @@ jobs:
1928
id-token: write
2029
contents: read
2130
env:
22-
GOPROXY: "https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@azr.artifactory.f5net.com/artifactory/api/go/f5-nginx-go-local-approved-dependency"
23-
outputs:
24-
agent_binary: ${{ steps.check_binary.outputs.agent_binary }}
25-
goversionm: ${{ steps.godeps.outputs.goversionm }}
26-
assertion_document: ${{ steps.assertiondoc.outputs.assertion-document-path }}
31+
GOPROXY: "https://${{ secrets.ARTIFACTORY_USER }}:${{ secrets.ARTIFACTORY_TOKEN }}@${{ secrets.ARTIFACTORY_URL }}"
2732
strategy:
28-
matrix:
29-
osarch: [amd64, arm64]
33+
matrix:
34+
osarch: [amd64, arm64]
3035
steps:
31-
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
32-
33-
- name: Set up Go
34-
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
36+
- name: Download nginx-agent binaries
37+
uses: actions/download-artifact@v3.0.2
3538
with:
36-
go-version-file: go.mod
37-
cache: false
39+
name: nginx-agent-binaries-${{ inputs.packageVersion }}
40+
path: ./artifacts
3841

3942
- name: Gather build dependencies
4043
id: godeps
4144
run: |
42-
if [ -z ${{inputs.branch}} ]; then
43-
echo "No branch input provided, using current branch: $GITHUB_REF_NAME"
44-
else
45-
echo "Checking out branch: ${{inputs.branch}}"
46-
git checkout ${{inputs.branch}}
47-
fi
48-
echo "Current branch: $GITHUB_REF_NAME"
49-
echo "branch_name=$GITHUB_REF_NAME" >> $GITHUB_ENV
50-
GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')
51-
echo "GO_VERSION=$GO_VERSION" >> $GITHUB_ENV
52-
echo "GO_VERSION=$GO_VERSION"
53-
echo "time_start=$(date +%s)" >> $GITHUB_ENV
54-
OSARCH=${{matrix.osarch}} make build
55-
echo "time_end=$(date +%s)" >> $GITHUB_ENV
56-
echo "Build time: $((time_end - time_start)) seconds"
57-
58-
echo "Getting sha256sum of the built nginx-agent binary..."
59-
echo "agent-digest=$(sha256sum build/nginx-agent | awk '{print $1}')" >> $GITHUB_ENV
60-
45+
ls -la artifacts/${{ matrix.osarch }}
46+
echo "agent_digest=$(cat artifacts/${{ matrix.osarch }}/nginx-agent.sha256)" >> $GITHUB_ENV
47+
echo "agent_buildstart=$(cat artifacts/${{ matrix.osarch }}/nginx-agent.buildstart)" >> $GITHUB_ENV
48+
echo "agent_buildend=$(cat artifacts/${{ matrix.osarch }}/nginx-agent.buildend)" >> $GITHUB_ENV
49+
6150
echo "Checking dependencies..."
62-
go version -m build/nginx-agent > goversionm_${{ github.run_id }}_${{ github.run_number }}.txt
51+
go version -m build/${{ matrix.osarch }}/nginx-agent > goversionm_${{ github.run_id }}_${{ github.run_number }}.txt
6352
ls -l goversionm_*.txt
6453
echo "goversionm=$(find -type f -name "goversionm*.txt" | head -n 1)" >> $GITHUB_ENV
6554

6655
- name: Generate Assertion Document
6756
id: assertiondoc
6857
uses: nginxinc/compliance-rules/.github/actions/assertion@83e452166aaf0ad8f07caf91a4f1f903b3dea1e6 # v0.3.0
6958
with:
70-
artifact-name: nginx-agent_${{ env.branch_name }}_${{ matrix.osarch }}
59+
artifact-name: nginx-agent_${{ github.ref_name }}_${{ matrix.osarch }}
7160
artifact-digest: ${{ env.agent-digest }}
7261
build-type: 'github'
7362
builder-id: 'github.com'
7463
builder-version: '${{env.GO_VERSION}}_test'
7564
invocation-id: ${{ github.run_id }}.${{ github.run_number }}.${{ github.run_attempt }}
76-
artifactory-user: ${{ secrets.ARTIFACTORY_USER }}
77-
artifactory-api-token: ${{ secrets.ARTIFACTORY_TOKEN }}
65+
artifactory-user: ${{ inputs.ARTIFACTORY_USER }}
66+
artifactory-api-token: ${{ inputs.ARTIFACTORY_TOKEN }}
7867
artifactory-url: ${{ secrets.ARTIFACTORY_URL }}
7968
artifactory-repo: 'f5-nginx-go-local-approved-dependency'
80-
assertion-doc-file: assertion_nginx-agent_${{env.branch_name}}_${{matrix.osarch}}.json
69+
assertion-doc-file: assertion_nginx-agent_${{ github.ref_name }}_${{matrix.osarch}}.json
8170
build-content-path: ${{ env.goversionm }}
82-
started-on: '${{ env.time_start }}'
83-
finished-on: '${{ env.time_end }}'
71+
started-on: '${{ env.agent_buildstart }}'
72+
finished-on: '${{ env.agent_buildend }}'
8473

8574
- name: Sign and Store Assertion Document
8675
id: sign

.github/workflows/release-branch.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ jobs:
204204
run: |
205205
git push origin "v${{ inputs.packageVersion }}"
206206
207-
upload-packages:
208-
name: Upload packages
207+
build-and-upload-packages:
208+
name: Build and upload release packages
209209
runs-on: ubuntu-22.04-amd64
210210
needs: [vars,release-draft,tag-release]
211211
permissions:
@@ -243,9 +243,17 @@ jobs:
243243
PACKAGE_BUILD: ${{ inputs.packageBuildNo }}
244244
run: |
245245
export PATH=$PATH:~/go/bin
246+
246247
echo "$GPG_KEY" | base64 --decode > ${NFPM_SIGNING_KEY_FILE}
247248
make package
248249
250+
- name: Archive Binaries
251+
uses: actions/upload-artifact@v3.1.2 # v3.1.2
252+
with:
253+
name: nginx-agent-binaries-${{ inputs.packageVersion }}
254+
path: |
255+
build/a*64
256+
249257
- name: Install GPG tools
250258
if: ${{ inputs.publishPackages == true }}
251259
run: |
@@ -261,14 +269,22 @@ jobs:
261269
let id_token = await core.getIDToken()
262270
core.setOutput('id_token', id_token)
263271
264-
- name: Publish Release Packages
272+
- name: Upload Release Packages
265273
if: ${{ inputs.publishPackages == true }}
266274
env:
267275
TOKEN: ${{ steps.idtoken.outputs.id_token }}
268276
UPLOAD_URL: ${{ inputs.uploadUrl }}
269277
run: |
270278
make release
271279
280+
- name: Generate assertion documents
281+
uses: .github/workflows/assertion.yml@${{ github.ref_name }}
282+
continue-on-error: true
283+
secrets:
284+
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
285+
ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }}
286+
ARTIFACTORY_URL: ${{ secrets.ARTIFACTORY_URL_PROD }}
287+
272288
merge-release:
273289
if: ${{ needs.vars.outputs.create_pull_request == 'true' }}
274290
name: Merge release branch back into main branch

Makefile.packaging

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,27 @@ $(PACKAGES_DIR):
3636

3737
.PHONY: package
3838
package: $(PACKAGES_DIR) #### Create final packages for all supported distros
39-
4039
# Build binaries for all supported architectures
4140
@for arch in $(DEB_ARCHS); do \
4241
mkdir -p $(BUILD_DIR)/$${arch}; \
4342
cp .nfpm.yaml .nfpm.$${arch}.yaml; \
4443
sed -i.bak "s/\^ARCH\^/$${arch}/g" ".nfpm.$${arch}.yaml"; \
4544
sed -i.bak "s/\^BUILD_PATH\^/\.\/build\/$${arch}/g" ".nfpm.$${arch}.yaml"; \
4645
echo "Building linux/$${arch}"; \
46+
start_time=$$(date +%s); \
4747
GOWORK=off CGO_ENABLED=0 GOARCH=$${arch} GOOS=linux \
4848
go build -pgo=auto -ldflags=${LDFLAGS} \
4949
-o $(BUILD_DIR)/$${arch}/$(BINARY_NAME) \
5050
$(PROJECT_DIR)/$(PROJECT_FILE); \
51-
rm -f .nfpm.$$arch.yaml.bak; \
51+
end_time=$$(date +%s); \
52+
rm -f .nfpm.$${arch}.yaml.bak; \
53+
sha256sum build/$${arch}/nginx-agent | awk '{print $$1}' > $(BUILD_DIR)/$${arch}/$(BINARY_NAME).sha256; \
54+
echo $${start_time} > $(BUILD_DIR)/$${arch}/$(BINARY_NAME).buildstart; \
55+
echo $${end_time} > $(BUILD_DIR)/$${arch}/$(BINARY_NAME).buildend; \
56+
echo "Built binary:"; \
5257
ls -la "$(BUILD_DIR)/$${arch}/$(BINARY_NAME)"; \
58+
cat $(BUILD_DIR)/$${arch}/$(BINARY_NAME).sha256; \
59+
echo "Built took "$$((end_time - start_time))" seconds"; \
5360
done; \
5461

5562
# Create deb packages

0 commit comments

Comments
 (0)