-
Notifications
You must be signed in to change notification settings - Fork 0
1380 lines (1213 loc) · 53.7 KB
/
release.yaml
File metadata and controls
1380 lines (1213 loc) · 53.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Reusable Release Workflow for ConductorOne Connectors
#
# Documentation:
# - docs/release-workflow.md - Pipeline overview, security properties, testing
# - docs/diagrams/DIAGRAM_RULES.md - When to update documentation
#
# When modifying this file, update documentation if you change:
# - Job structure or dependencies → update docs/diagrams/release-workflow.dot
# - Security properties → update docs/release-workflow.md
# - Run `make docs` to regenerate the diagram
name: Reusable Release Workflow
on:
workflow_call:
inputs:
tag:
required: true
type: string
lambda:
required: false
type: boolean
default: true
description: "Whether to release with Lambda image support."
docker:
required: false
type: boolean
default: true
description: "Whether to release with Docker image support."
dockerfile_template:
required: false
type: string
default: ""
description: "Path to a custom Dockerfile template in the caller repo (relative to repo root). Only valid when lambda is false. Supports ${REPO_NAME} substitution."
docker_extra_files:
required: false
type: string
default: ""
description: "Comma-separated list of extra files/directories from the caller repo to include in the Docker build context (e.g., 'java,config'). Only valid when dockerfile_template is set."
msi:
required: false
type: boolean
default: true
description: "Whether to build MSI Windows installers."
msi_wxs_path:
required: false
type: string
default: ""
description: "Path to a custom WXS file in the caller repo for MSI generation (relative to repo root). If not provided, uses default template."
secrets:
RELENG_GITHUB_TOKEN:
required: true
APPLE_SIGNING_KEY_P12:
required: true
APPLE_SIGNING_KEY_P12_PASSWORD:
required: true
AC_PASSWORD:
required: true
AC_PROVIDER:
required: true
DATADOG_API_KEY:
required: true
GORELEASER_PRO_KEY:
required: false
description: "GoReleaser Pro license key for MSI builds. Required when msi is true."
env:
CDN_BASE_URL: "https://dist.conductorone.com"
S3_BUCKET: "connector-artifact-registry"
GENERATED_DIR: "_generated"
jobs:
validate-inputs:
runs-on: ubuntu-latest
steps:
- name: Validate tag format
run: |
TAG="${{ inputs.tag }}"
# Strict semver regex with 'v' prefix (per https://semver.org)
# Supports: v1.2.3, v1.2.3-alpha, v1.2.3-alpha.1, v1.2.3+build, v1.2.3-rc.1+build.123
SEMVER_REGEX='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$'
if [[ ! "$TAG" =~ $SEMVER_REGEX ]]; then
echo "::error::Tag must be valid semver starting with 'v' (e.g., v1.2.3, v1.0.0-rc.1). Got: $TAG"
exit 1
fi
echo "✅ Tag format valid: $TAG"
- name: Validate dockerfile_template requires lambda=false
if: inputs.dockerfile_template != '' && inputs.lambda == true
run: |
echo "::error::dockerfile_template can only be used when lambda is false"
exit 1
- name: Validate docker_extra_files requires dockerfile_template
if: inputs.docker_extra_files != '' && inputs.dockerfile_template == ''
run: |
echo "::error::docker_extra_files can only be used when dockerfile_template is set"
exit 1
- name: Validate msi_wxs_path has no path traversal
if: inputs.msi_wxs_path != ''
run: |
WXS_PATH="${{ inputs.msi_wxs_path }}"
if [[ "$WXS_PATH" == /* ]] || [[ "$WXS_PATH" == *".."* ]]; then
echo "::error::msi_wxs_path must be a relative path without '..' traversal. Got: $WXS_PATH"
exit 1
fi
- name: Validate GORELEASER_PRO_KEY when msi enabled
if: inputs.msi == true
env:
HAS_KEY: ${{ secrets.GORELEASER_PRO_KEY != '' }}
run: |
if [ "$HAS_KEY" != "true" ]; then
echo "::error::GORELEASER_PRO_KEY secret is required when msi is true"
exit 1
fi
determine-workflows-ref:
needs: validate-inputs
runs-on: ubuntu-latest
permissions:
actions: read
outputs:
ref: ${{ steps.workflow-version.outputs.sha }}
steps:
- name: Determine workflows ref
id: workflow-version
uses: canonical/get-workflow-version-action@v1
with:
repository-name: "ConductorOne/github-workflows"
file-name: "release.yaml"
github-token: ${{ secrets.GITHUB_TOKEN }}
goreleaser-binaries:
needs: determine-workflows-ref
runs-on: macos-latest
permissions:
contents: read
id-token: write # <-- needed for cosign keyless (OIDC)
outputs:
s3_directory: ${{ steps.s3-directory.outputs.S3_DIRECTORY }}
binaries_manifest: ${{ steps.generate-binaries-manifest.outputs.binaries_manifest }}
binaries_checksums: ${{ steps.output-checksums.outputs.checksums }}
steps:
- name: Checkout caller repo
uses: actions/checkout@v5
with:
path: _caller
repository: ${{ github.event.repository.full_name }}
fetch-depth: 0
- name: Checkout connector workflows
uses: actions/checkout@v5
with:
path: _workflows
repository: ConductorOne/github-workflows
ref: ${{ needs.determine-workflows-ref.outputs.ref }}
- name: Set up Go for caller
uses: actions/setup-go@v6
with:
go-version-file: "_caller/go.mod"
- name: Calculate S3 directory
id: s3-directory
shell: bash
run: |
ORG="${{ github.event.repository.owner.login }}"
REPO="${{ github.event.repository.name }}"
TAG="${{ inputs.tag }}"
echo "S3_DIRECTORY=releases/$ORG/$REPO/$TAG" >> "$GITHUB_OUTPUT"
- name: Generate configs for binaries
working-directory: _workflows
env:
REPO_NAME: ${{ github.event.repository.name }}
S3_BUCKET: ${{ env.S3_BUCKET }}
S3_REGION: "us-west-2"
S3_DIRECTORY: ${{ steps.s3-directory.outputs.S3_DIRECTORY }}
# For provenance predicate template
WORKFLOWS_REF: ${{ needs.determine-workflows-ref.outputs.ref }}
RELEASE_TAG: ${{ inputs.tag }}
run: |
mkdir -p "${GENERATED_DIR}"
export BUILD_STARTED_ON=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
envsubst < .gon-amd64-template.json | tee "${GENERATED_DIR}/.gon-amd64.json"
envsubst < .gon-arm64-template.json | tee "${GENERATED_DIR}/.gon-arm64.json"
envsubst < templates/.goreleaser-binaries-template.yaml.tmpl | tee "${GENERATED_DIR}/.goreleaser.binaries.yaml"
envsubst < templates/.slsa-provenance-predicate-template.json.tmpl | tee "${GENERATED_DIR}/predicate.json"
- name: Set up Gon
run: brew tap conductorone/gon && brew install conductorone/gon/gon
- name: Import Keychain Certs
uses: apple-actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.APPLE_SIGNING_KEY_P12 }}
p12-password: ${{ secrets.APPLE_SIGNING_KEY_P12_PASSWORD }}
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Download syft
uses: anchore/sbom-action/download-syft@v0
- name: Configure AWS credentials via OIDC
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: arn:aws:iam::025044153841:role/GHA-Artifacts-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }}
aws-region: us-west-2
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
workdir: _caller
version: "~> v2.13"
args: release --clean --config ../_workflows/_generated/.goreleaser.binaries.yaml
env:
GITHUB_TOKEN: ${{ secrets.RELENG_GITHUB_TOKEN }}
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
AC_PROVIDER: ${{ secrets.AC_PROVIDER }}
- name: Generate SLSA provenance for archives
working-directory: _workflows
env:
CALLER_DIST: ../_caller/dist
shell: bash
run: |
set -euo pipefail
PROVENANCE_COUNT=0
# Find all downloadable archives (not checksums, not signatures, not sboms)
for artifact in "${CALLER_DIST}"/*.zip "${CALLER_DIST}"/*.tar.gz; do
[ -f "$artifact" ] || continue
# Skip if it's not an archive we want to attest
[[ "$artifact" == *checksums* ]] && continue
BASENAME=$(basename "$artifact")
echo "Generating provenance for: $BASENAME"
cosign attest-blob \
--yes \
--predicate "${GENERATED_DIR}/predicate.json" \
--type slsaprovenance1 \
--bundle "${CALLER_DIST}/${BASENAME}.provenance.sigstore.json" \
"$artifact" > /dev/null
echo "✅ Created ${BASENAME}.provenance.sigstore.json"
((PROVENANCE_COUNT++)) || true
done
# Note: checksums provenance is generated in publish-release-manifest job
# after merging with Windows hashes
echo "Generated provenance bundles: ${PROVENANCE_COUNT}"
if [ "$PROVENANCE_COUNT" -eq 0 ]; then
echo "::error::No provenance bundles were generated - this indicates a build problem"
exit 1
fi
ls "${CALLER_DIST}"/*.provenance.sigstore.json
- name: Sign SBOMs as attestation bundles
working-directory: _workflows
env:
CALLER_DIST: ../_caller/dist
shell: bash
run: |
set -euo pipefail
SIGNED_COUNT=0
# Find all SBOM files generated by GoReleaser (syft)
# GoReleaser names SBOMs as: archive.zip.sbom.json or archive.tar.gz.sbom.json
for sbom in "${CALLER_DIST}"/*.sbom.json; do
[ -f "$sbom" ] || continue
# Get the archive filename (remove .sbom.json suffix)
# e.g., "baton-foo-v1.0.0-darwin-amd64.zip.sbom.json" -> "baton-foo-v1.0.0-darwin-amd64.zip"
SBOM_BASENAME=$(basename "$sbom")
ARCHIVE_NAME="${SBOM_BASENAME%.sbom.json}"
# The archive name after stripping .sbom.json already includes the extension (.zip or .tar.gz)
ARCHIVE="${CALLER_DIST}/${ARCHIVE_NAME}"
if [ ! -f "$ARCHIVE" ]; then
echo "::error::Could not find archive for SBOM: $sbom (expected: $ARCHIVE)"
exit 1
fi
echo "Signing SBOM for: $(basename "$ARCHIVE")"
cosign attest-blob \
--yes \
--predicate "$sbom" \
--type https://spdx.dev/Document \
--bundle "${ARCHIVE}.sbom.sigstore.json" \
"$ARCHIVE" > /dev/null
echo "✅ Created $(basename "$ARCHIVE").sbom.sigstore.json"
((SIGNED_COUNT++)) || true
done
echo "Generated SBOM bundles: ${SIGNED_COUNT}"
ls "${CALLER_DIST}"/*.sbom.sigstore.json 2>/dev/null || echo "ℹ️ No SBOM bundles generated (GoReleaser may not have generated SBOMs)"
- name: Upload attestation bundles to S3
working-directory: _workflows
env:
CALLER_DIST: ../_caller/dist
shell: bash
run: |
set -euo pipefail
BUCKET="${{ env.S3_BUCKET }}"
DIRECTORY="${{ steps.s3-directory.outputs.S3_DIRECTORY }}"
UPLOAD_COUNT=0
# Upload all sigstore bundles (provenance and SBOM)
for bundle in "${CALLER_DIST}"/*.sigstore.json; do
[ -f "$bundle" ] || continue
BASENAME=$(basename "$bundle")
echo "Uploading $BASENAME to S3..."
aws s3 cp "$bundle" "s3://$BUCKET/$DIRECTORY/$BASENAME" \
--cache-control "public,max-age=31536000,immutable" \
--content-type "application/json"
((UPLOAD_COUNT++))
done
if [ "$UPLOAD_COUNT" -eq 0 ]; then
echo "::error::No attestation bundles found to upload"
exit 1
fi
echo "✅ Uploaded ${UPLOAD_COUNT} attestation bundles to S3"
- name: Set up Go for workflows
uses: actions/setup-go@v6
with:
go-version-file: "_workflows/go.mod"
- name: Generate manifest.json
id: generate-binaries-manifest
working-directory: _workflows
env:
CALLER_DIST: ../_caller/dist
run: |
MANIFEST_JSON=$(go run ./cmd/generate-manifest \
-asset-dir "${CALLER_DIST}" \
-repo-name "${{ github.event.repository.name }}" \
-org-name "${{ github.event.repository.owner.login }}" \
-tag "${{ inputs.tag }}" \
-base-url "${{ env.CDN_BASE_URL }}/${{ steps.s3-directory.outputs.S3_DIRECTORY }}")
# Debug output
echo "$MANIFEST_JSON"
# Write to GITHUB_OUTPUT for job output
{
echo "binaries_manifest<<EOF"
echo "$MANIFEST_JSON"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Output checksums for merging
id: output-checksums
working-directory: _caller
run: |
# Find the checksums file generated by GoReleaser
CHECKSUMS_FILE=$(ls dist/*checksums*.txt 2>/dev/null | head -1)
if [ -z "$CHECKSUMS_FILE" ]; then
echo "::error::No checksums file found"
exit 1
fi
echo "Found checksums file: $CHECKSUMS_FILE"
# Output checksums content for merging with Windows hashes in registry job
# Use randomized delimiter to prevent injection via filenames containing "EOF"
DELIM="CHECKSUMS_$(openssl rand -hex 8)"
{
echo "checksums<<${DELIM}"
cat "$CHECKSUMS_FILE"
echo "${DELIM}"
} >> "$GITHUB_OUTPUT"
goreleaser-windows:
if: inputs.msi == true
needs: determine-workflows-ref
runs-on: windows-latest
permissions:
contents: read
id-token: write
outputs:
windows_manifest: ${{ steps.generate-windows-manifest.outputs.windows_manifest }}
steps:
- name: Checkout caller repo
uses: actions/checkout@v5
with:
path: _caller
repository: ${{ github.event.repository.full_name }}
fetch-depth: 0
- name: Checkout connector workflows
uses: actions/checkout@v5
with:
path: _workflows
repository: ConductorOne/github-workflows
ref: ${{ needs.determine-workflows-ref.outputs.ref }}
- name: Set up Go for caller
uses: actions/setup-go@v6
with:
go-version-file: "_caller/go.mod"
- name: Generate or locate WXS file
id: wxs
shell: pwsh
env:
REPO_NAME: ${{ github.event.repository.name }}
CUSTOM_WXS: ${{ inputs.msi_wxs_path }}
run: |
New-Item -ItemType Directory -Force -Path "_workflows/_generated"
if ($env:CUSTOM_WXS -ne "") {
# Use custom WXS from caller repo
$wxsPath = "_caller/$env:CUSTOM_WXS"
if (-not (Test-Path $wxsPath)) {
Write-Error "Custom WXS file not found: $env:CUSTOM_WXS"
exit 1
}
Write-Host "Using custom WXS: $wxsPath"
Copy-Item $wxsPath "_workflows/_generated/app.wxs"
"wxs_path=../_workflows/_generated/app.wxs" >> $env:GITHUB_OUTPUT
} else {
# Generate WXS from default template with deterministic UpgradeCode
Write-Host "Using default WXS template"
# Generate deterministic UUID v5 from repo name using Python's standard library
# Uses URL namespace (6ba7b810-9dad-11d1-80b4-00c04fd430c8) per RFC 4122
$upgradeCode = (python -c "import uuid; print(str(uuid.uuid5(uuid.NAMESPACE_URL, '$env:REPO_NAME')).upper())")
Write-Host "Generated UpgradeCode for $env:REPO_NAME`: $upgradeCode"
# Read template and substitute UpgradeCode
$template = Get-Content "_workflows/templates/.wxs-default-template.wxs" -Raw
$template = $template -replace '\$\{UPGRADE_CODE\}', $upgradeCode
$template | Out-File "_workflows/_generated/app.wxs" -Encoding utf8
"wxs_path=../_workflows/_generated/app.wxs" >> $env:GITHUB_OUTPUT
}
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Download syft
uses: anchore/sbom-action/download-syft@v0
- name: Generate configs for Windows
working-directory: _workflows
shell: bash
env:
REPO_NAME: ${{ github.event.repository.name }}
WXS_PATH: ${{ steps.wxs.outputs.wxs_path }}
WORKFLOWS_REF: ${{ needs.determine-workflows-ref.outputs.ref }}
RELEASE_TAG: ${{ inputs.tag }}
run: |
export BUILD_STARTED_ON=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Generate GoReleaser config
envsubst < templates/.goreleaser-windows-template.yaml.tmpl | tee "_generated/.goreleaser.windows.yaml"
# Generate provenance predicate
envsubst < templates/.slsa-provenance-predicate-template.json.tmpl | tee "_generated/predicate.json"
- name: Run GoReleaser for Windows
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser-pro
workdir: _caller
version: "~> v2.13"
args: release --clean --skip=publish --config ../_workflows/_generated/.goreleaser.windows.yaml
env:
GITHUB_TOKEN: ${{ secrets.RELENG_GITHUB_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_PRO_KEY }}
- name: Flatten MSI directory structure
shell: pwsh
run: |
# GoReleaser Pro puts MSI files in dist/msi/<name>/ subdirectory
# Copy all files to dist root to match binaries job pattern
$msiDir = "_caller/dist/msi"
if (Test-Path $msiDir) {
Get-ChildItem $msiDir -Recurse -File | ForEach-Object {
Write-Host "Copying $($_.Name) to dist root"
Copy-Item $_.FullName -Destination "_caller/dist/"
}
Write-Host "✅ Flattened MSI directory structure"
}
- name: Generate SLSA provenance for Windows artifacts
working-directory: _workflows
shell: bash
env:
CALLER_DIST: ../_caller/dist
run: |
set -euo pipefail
PROVENANCE_COUNT=0
# Find all downloadable archives (zip and msi files)
# MSI files are flattened to dist root by previous step
for artifact in "${CALLER_DIST}"/*.zip "${CALLER_DIST}"/*.msi; do
[ -f "$artifact" ] || continue
[[ "$artifact" == *checksums* ]] && continue
BASENAME=$(basename "$artifact")
echo "Generating provenance for: $BASENAME"
cosign attest-blob \
--yes \
--predicate "_generated/predicate.json" \
--type slsaprovenance1 \
--bundle "${CALLER_DIST}/${BASENAME}.provenance.sigstore.json" \
"$artifact" > /dev/null
echo "✅ Created ${BASENAME}.provenance.sigstore.json"
((PROVENANCE_COUNT++)) || true
done
echo "Generated provenance bundles: ${PROVENANCE_COUNT}"
if [ "$PROVENANCE_COUNT" -eq 0 ]; then
echo "::error::No provenance bundles were generated - this indicates a build problem"
exit 1
fi
ls "${CALLER_DIST}"/*.provenance.sigstore.json
- name: Sign SBOMs as attestation bundles
working-directory: _workflows
shell: bash
env:
CALLER_DIST: ../_caller/dist
run: |
set -euo pipefail
SIGNED_COUNT=0
# Find all SBOM files generated by GoReleaser (syft)
# All files are in dist root (MSI files flattened by previous step)
for sbom in "${CALLER_DIST}"/*.sbom.json; do
[ -f "$sbom" ] || continue
SBOM_BASENAME=$(basename "$sbom")
ARCHIVE_NAME="${SBOM_BASENAME%.sbom.json}"
ARCHIVE="${CALLER_DIST}/${ARCHIVE_NAME}"
if [ ! -f "$ARCHIVE" ]; then
echo "::error::Could not find archive for SBOM: $sbom (expected: $ARCHIVE)"
exit 1
fi
echo "Signing SBOM for: $(basename "$ARCHIVE")"
cosign attest-blob \
--yes \
--predicate "$sbom" \
--type https://spdx.dev/Document \
--bundle "${ARCHIVE}.sbom.sigstore.json" \
"$ARCHIVE" > /dev/null
echo "✅ Created $(basename "$ARCHIVE").sbom.sigstore.json"
((SIGNED_COUNT++)) || true
done
echo "Generated SBOM bundles: ${SIGNED_COUNT}"
ls "${CALLER_DIST}"/*.sbom.sigstore.json 2>/dev/null || echo "ℹ️ No SBOM bundles generated (GoReleaser may not have generated SBOMs)"
- name: Configure AWS credentials via OIDC
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: arn:aws:iam::025044153841:role/GHA-Artifacts-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }}
aws-region: us-west-2
- name: Calculate S3 directory
id: s3-directory
shell: pwsh
run: |
$org = "${{ github.event.repository.owner.login }}"
$repo = "${{ github.event.repository.name }}"
$tag = "${{ inputs.tag }}"
"S3_DIRECTORY=releases/$org/$repo/$tag" >> $env:GITHUB_OUTPUT
- name: Upload Windows artifacts to S3
shell: pwsh
env:
S3_BUCKET: ${{ env.S3_BUCKET }}
S3_DIRECTORY: ${{ steps.s3-directory.outputs.S3_DIRECTORY }}
run: |
# Upload zip files
$zipFiles = Get-ChildItem "_caller/dist/*.zip" -ErrorAction SilentlyContinue
foreach ($zip in $zipFiles) {
Write-Host "Uploading $($zip.Name) to S3..."
aws s3 cp $zip.FullName "s3://$env:S3_BUCKET/$env:S3_DIRECTORY/$($zip.Name)" `
--cache-control "public,max-age=31536000,immutable" `
--content-type "application/zip"
}
# Upload MSI files (flattened to dist root by earlier step)
$msiFiles = Get-ChildItem "_caller/dist/*.msi" -ErrorAction SilentlyContinue
foreach ($msi in $msiFiles) {
Write-Host "Uploading $($msi.Name) to S3..."
aws s3 cp $msi.FullName "s3://$env:S3_BUCKET/$env:S3_DIRECTORY/$($msi.Name)" `
--cache-control "public,max-age=31536000,immutable" `
--content-type "application/x-msi"
}
# Upload signatures (.sig files)
$sigFiles = Get-ChildItem "_caller/dist/*.sig" -ErrorAction SilentlyContinue
foreach ($sig in $sigFiles) {
Write-Host "Uploading $($sig.Name) to S3..."
aws s3 cp $sig.FullName "s3://$env:S3_BUCKET/$env:S3_DIRECTORY/$($sig.Name)" `
--cache-control "public,max-age=31536000,immutable" `
--content-type "application/octet-stream"
}
# Upload certificates (.cert files)
$certFiles = Get-ChildItem "_caller/dist/*.cert" -ErrorAction SilentlyContinue
foreach ($cert in $certFiles) {
Write-Host "Uploading $($cert.Name) to S3..."
aws s3 cp $cert.FullName "s3://$env:S3_BUCKET/$env:S3_DIRECTORY/$($cert.Name)" `
--cache-control "public,max-age=31536000,immutable" `
--content-type "application/x-pem-file"
}
# Upload SBOM json files (before attestation signing)
$sbomFiles = Get-ChildItem "_caller/dist/*.sbom.json" -ErrorAction SilentlyContinue
foreach ($sbom in $sbomFiles) {
Write-Host "Uploading $($sbom.Name) to S3..."
aws s3 cp $sbom.FullName "s3://$env:S3_BUCKET/$env:S3_DIRECTORY/$($sbom.Name)" `
--cache-control "public,max-age=31536000,immutable" `
--content-type "application/json"
}
# Upload attestation bundles (provenance and SBOM sigstore bundles)
$bundles = Get-ChildItem "_caller/dist/*.sigstore.json" -ErrorAction SilentlyContinue
foreach ($bundle in $bundles) {
Write-Host "Uploading $($bundle.Name) to S3..."
aws s3 cp $bundle.FullName "s3://$env:S3_BUCKET/$env:S3_DIRECTORY/$($bundle.Name)" `
--cache-control "public,max-age=31536000,immutable" `
--content-type "application/json"
}
- name: Set up Go for workflows tools
uses: actions/setup-go@v6
with:
go-version-file: "_workflows/go.mod"
- name: Generate Windows manifest
id: generate-windows-manifest
working-directory: _workflows
shell: bash
env:
CDN_BASE_URL: ${{ env.CDN_BASE_URL }}
S3_DIRECTORY: ${{ steps.s3-directory.outputs.S3_DIRECTORY }}
run: |
# Use Go tool for type-safe manifest generation
MANIFEST=$(go run ./cmd/generate-windows-manifest \
-dist-dir "../_caller/dist" \
-cdn-base-url "$CDN_BASE_URL" \
-s3-directory "$S3_DIRECTORY")
echo "Windows manifest: $MANIFEST"
{
echo "windows_manifest<<MANIFEST_EOF"
echo "$MANIFEST"
echo "MANIFEST_EOF"
} >> "$GITHUB_OUTPUT"
goreleaser-docker:
if: inputs.docker == true || inputs.lambda == true
needs: determine-workflows-ref
permissions:
id-token: write
contents: read
outputs:
images_manifest: ${{ steps.extract-images.outputs.images_manifest }}
runs-on: ubuntu-latest
steps:
- name: Checkout caller repo
uses: actions/checkout@v5
with:
path: _caller
repository: ${{ github.event.repository.full_name }}
fetch-depth: 0
- name: Checkout connector workflows
if: inputs.docker == true || inputs.lambda == true
uses: actions/checkout@v5
with:
path: _workflows
repository: ConductorOne/github-workflows
ref: ${{ needs.determine-workflows-ref.outputs.ref }}
- name: Set up Go for caller
if: inputs.docker == true || inputs.lambda == true
uses: actions/setup-go@v6
with:
go-version-file: "_caller/go.mod"
- name: Install cosign
if: inputs.docker == true
uses: sigstore/cosign-installer@v3
- name: Generate configs for Docker OCI
if: inputs.docker == true
working-directory: _workflows
env:
REPO_NAME: ${{ github.event.repository.name }}
DOCKERFILE_PATH: ../_workflows/_generated/Dockerfile
DIST_DIR: dist/oci
# For provenance predicate template
WORKFLOWS_REF: ${{ needs.determine-workflows-ref.outputs.ref }}
RELEASE_TAG: ${{ inputs.tag }}
# Custom Dockerfile template from caller repo (if provided)
CUSTOM_DOCKERFILE_TEMPLATE: ${{ inputs.dockerfile_template }}
# Extra files to include in Docker build context (comma-separated)
DOCKER_EXTRA_FILES: ${{ inputs.docker_extra_files }}
run: |
mkdir -p "${GENERATED_DIR}"
export BUILD_STARTED_ON=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Generate Dockerfile from custom template or default
if [ -n "${CUSTOM_DOCKERFILE_TEMPLATE}" ]; then
CUSTOM_PATH="../_caller/${CUSTOM_DOCKERFILE_TEMPLATE}"
if [ ! -f "${CUSTOM_PATH}" ]; then
echo "::error::Custom Dockerfile template not found: ${CUSTOM_DOCKERFILE_TEMPLATE}"
exit 1
fi
echo "Using custom Dockerfile template: ${CUSTOM_DOCKERFILE_TEMPLATE}"
envsubst '$REPO_NAME' < "${CUSTOM_PATH}" | tee "${GENERATED_DIR}/Dockerfile"
else
echo "Using default Dockerfile template"
envsubst '$REPO_NAME' < templates/.Dockerfile-template.tmpl | tee "${GENERATED_DIR}/Dockerfile"
fi
# Build EXTRA_FILES_BLOCK for goreleaser template substitution
# This will be empty string if no extra files, or the YAML block if specified
export EXTRA_FILES_BLOCK=""
if [ -n "${DOCKER_EXTRA_FILES}" ]; then
echo "Adding extra files to Docker build context: ${DOCKER_EXTRA_FILES}"
# Validate files exist and build the YAML block
EXTRA_FILES_BLOCK=" extra_files:"$'\n'
IFS=',' read -ra FILES <<< "${DOCKER_EXTRA_FILES}"
for file in "${FILES[@]}"; do
file=$(echo "$file" | xargs) # trim whitespace
if [ ! -e "../_caller/${file}" ]; then
echo "::error::Extra file/directory not found: ${file}"
exit 1
fi
EXTRA_FILES_BLOCK="${EXTRA_FILES_BLOCK} - ${file}"$'\n'
done
export EXTRA_FILES_BLOCK
fi
# Generate goreleaser config with all substitutions
envsubst < templates/.goreleaser-docker-oci-template.yaml.tmpl | tee "${GENERATED_DIR}/.goreleaser.docker.yaml"
envsubst < templates/.slsa-provenance-predicate-template.json.tmpl | tee "${GENERATED_DIR}/predicate.json"
- name: Generate configs for Lambda
if: inputs.lambda == true
working-directory: _workflows
env:
REPO_NAME: ${{ github.event.repository.name }}
DOCKERFILE_LAMBDA_PATH: ../_workflows/_generated/Dockerfile.lambda
DIST_DIR: dist/lambda
run: |
mkdir -p "${GENERATED_DIR}"
envsubst '$REPO_NAME' < templates/.Dockerfile-lambda-template.tmpl | tee "${GENERATED_DIR}/Dockerfile.lambda"
envsubst < templates/.goreleaser-docker-lambda-template.yaml.tmpl | tee "${GENERATED_DIR}/.goreleaser.lambda.yaml"
- name: Set up QEMU
if: inputs.docker == true || inputs.lambda == true
uses: docker/setup-qemu-action@v3
with:
platforms: linux/arm64
- name: Set up Docker Buildx
if: inputs.docker == true || inputs.lambda == true
uses: docker/setup-buildx-action@v3
- name: Configure Public ECR AWS credentials via OIDC
if: inputs.docker == true
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: arn:aws:iam::025044153841:role/GHA-Artifacts-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }}
aws-region: us-east-1
- name: Login to Public ECR
if: inputs.docker == true
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Run GoReleaser for Docker OCI
if: inputs.docker == true
uses: goreleaser/goreleaser-action@v6
with:
workdir: _caller
version: "~> v2.13"
args: release --clean --config ../_workflows/_generated/.goreleaser.docker.yaml
env:
GITHUB_TOKEN: ${{ secrets.RELENG_GITHUB_TOKEN }}
COSIGN_EXPERIMENTAL: "1"
- name: Configure Lambda ECR AWS credentials via OIDC
if: inputs.lambda == true
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: "arn:aws:iam::168442440833:role/GitHubActionsECRPushRole-${{ github.event.repository.name }}"
aws-region: us-west-2
- name: Login to Lambda ECR
if: inputs.lambda == true
uses: aws-actions/amazon-ecr-login@v2
- name: Run GoReleaser for Lambda
if: inputs.lambda == true
uses: goreleaser/goreleaser-action@v6
with:
workdir: _caller
version: "~> v2.13"
args: release --clean --config ../_workflows/_generated/.goreleaser.lambda.yaml
env:
GITHUB_TOKEN: ${{ secrets.RELENG_GITHUB_TOKEN }}
- name: Set up Go for workflows
if: inputs.docker == true || inputs.lambda == true
uses: actions/setup-go@v6
with:
go-version-file: "_workflows/go.mod"
- name: Extract image digests from GoReleaser assets
id: extract-images
if: inputs.docker == true || inputs.lambda == true
working-directory: _workflows
env:
CALLER_DIST_OCI: ../_caller/dist/oci
CALLER_DIST_LAMBDA: ../_caller/dist/lambda
run: |
IMAGES_JSON=$(go run ./cmd/extract-images \
-include-public=${{ inputs.docker }} \
-include-lambda=${{ inputs.lambda }} \
-asset-dir "${CALLER_DIST_OCI}" \
-lambda-asset-dir "${CALLER_DIST_LAMBDA}" \
-repo-name "${{ github.event.repository.name }}" \
-tag "${{ inputs.tag }}")
# Debug output
echo "$IMAGES_JSON"
# Write to GITHUB_OUTPUT for job output
{
echo "images_manifest<<EOF"
echo "$IMAGES_JSON"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Generate SLSA provenance for images
if: inputs.docker == true
working-directory: _workflows
env:
RELEASE_TAG: ${{ inputs.tag }}
CALLER_DIST_OCI: ../_caller/dist/oci
shell: bash
run: |
set -euo pipefail
VERSION="${RELEASE_TAG#v}" # Remove 'v' prefix
# Read digests from the digest file
DIGEST_FILE="${CALLER_DIST_OCI}/${{ github.event.repository.name }}_${VERSION}_digests.txt"
if [ ! -f "$DIGEST_FILE" ]; then
echo "::warning::Digest file not found: $DIGEST_FILE"
exit 0
fi
# Attest each multi-arch index image (tagged with just version, not version-arch)
while IFS= read -r line || [ -n "$line" ]; do
[ -z "$line" ] && continue
DIGEST_HEX=$(echo "$line" | awk '{print $1}')
REF=$(echo "$line" | awk '{print $2}')
# Only attest multi-arch index images (tagged with just version)
if [[ "$REF" != *":${VERSION}" ]]; then
continue
fi
# Build the digest-pinned reference
IMAGE_BASE="${REF%:*}"
URI="${IMAGE_BASE}@sha256:${DIGEST_HEX}"
echo "Attesting image: $URI"
cosign attest \
--yes \
--type https://slsa.dev/provenance/v1 \
--predicate "${GENERATED_DIR}/predicate.json" \
"$URI"
echo "✅ Attested $URI"
done < "$DIGEST_FILE"
publish-release-manifest:
# Release manifest publication: manifest + checksums + S3 upload.
# Require binaries to succeed; windows and docker may be skipped based on inputs.
# Each optional job must succeed if it ran — a failure means incomplete release artifacts.
# see: https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution
if: ${{ !cancelled() && needs.goreleaser-binaries.result == 'success' && (needs.goreleaser-windows.result == 'success' || needs.goreleaser-windows.result == 'skipped') && (needs.goreleaser-docker.result == 'success' || needs.goreleaser-docker.result == 'skipped') }}
needs: [determine-workflows-ref, goreleaser-binaries, goreleaser-windows, goreleaser-docker]
outputs:
merged_manifest: ${{ steps.export-manifest.outputs.merged_manifest }}
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout connector workflows
uses: actions/checkout@v5
with:
path: _workflows
repository: ConductorOne/github-workflows
ref: ${{ needs.determine-workflows-ref.outputs.ref }}
- name: Set up Go for workflows
uses: actions/setup-go@v6
with:
go-version-file: "_workflows/go.mod"
- name: Merge binaries, Windows, and images manifests
working-directory: _workflows
env:
BINARIES_MANIFEST: ${{ needs.goreleaser-binaries.outputs.binaries_manifest }}
WINDOWS_MANIFEST: ${{ needs.goreleaser-windows.outputs.windows_manifest }}
IMAGES_MANIFEST: ${{ needs.goreleaser-docker.outputs.images_manifest }}
OUTPUT_DIR: _output
run: |
mkdir -p "${OUTPUT_DIR}"
go run ./cmd/merge-manifests \
-binaries-manifest "$BINARIES_MANIFEST" \
-windows-manifest "$WINDOWS_MANIFEST" \
-images-manifest "$IMAGES_MANIFEST" \
| tee "${OUTPUT_DIR}/manifest.json"
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Sign manifest.json
working-directory: _workflows/_output
env: { COSIGN_EXPERIMENTAL: "1" }
shell: bash
run: |
set -euo pipefail
cosign sign-blob --yes "manifest.json" \
--output-signature "manifest.json.sig" \
--output-certificate "manifest.json.cert"
- name: Configure AWS credentials via OIDC
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: arn:aws:iam::025044153841:role/GHA-Artifacts-${{ github.event.repository.owner.login }}-${{ github.event.repository.name }}
aws-region: us-west-2
- name: Create unified checksums file
working-directory: _workflows/_output
env:
BINARIES_CHECKSUMS: ${{ needs.goreleaser-binaries.outputs.binaries_checksums }}
WINDOWS_MANIFEST: ${{ needs.goreleaser-windows.outputs.windows_manifest }}
REPO_NAME: ${{ github.event.repository.name }}
VERSION: ${{ inputs.tag }}
shell: bash
run: |
set -euo pipefail
# Determine checksums filename (matches GoReleaser default pattern)
VERSION_NO_V="${VERSION#v}"
CHECKSUMS_FILE="${REPO_NAME}_${VERSION_NO_V}_checksums.txt"
# Start with binaries checksums
echo "Creating unified checksums file: $CHECKSUMS_FILE"
echo "$BINARIES_CHECKSUMS" > "./${CHECKSUMS_FILE}"
# Append Windows asset hashes from manifest
# Format: <sha256> <filename>
if [ -n "$WINDOWS_MANIFEST" ] && [ "$WINDOWS_MANIFEST" != "{}" ]; then
echo "Appending Windows hashes..."
echo "$WINDOWS_MANIFEST" | jq -r 'to_entries[] | "\(.value.sha256) \(.value.filename)"' >> "./${CHECKSUMS_FILE}"
fi
echo "Unified checksums file:"
cat "./${CHECKSUMS_FILE}"
# Sign the checksums file
echo "Signing checksums file..."
cosign sign-blob --yes "./${CHECKSUMS_FILE}" \
--output-signature "./${CHECKSUMS_FILE}.sig" \
--output-certificate "./${CHECKSUMS_FILE}.cert"