-
Notifications
You must be signed in to change notification settings - Fork 776
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: generate sbom and provenance (#2540)
Signed-off-by: Sertac Ozercan <[email protected]>
- Loading branch information
Showing
14 changed files
with
402 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: pre-release | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
permissions: read-all | ||
|
||
env: | ||
IMAGE_REPO: openpolicyagent/gatekeeper | ||
CRD_IMAGE_REPO: openpolicyagent/gatekeeper-crds | ||
GATOR_IMAGE_REPO: openpolicyagent/gator | ||
|
||
jobs: | ||
pre-release: | ||
name: "Pre Release" | ||
runs-on: "ubuntu-22.04" | ||
if: github.ref == 'refs/heads/master' && github.event_name == 'push' && github.repository == 'open-policy-agent/gatekeeper' | ||
timeout-minutes: 30 | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c | ||
|
||
- name: Publish development | ||
run: | | ||
make docker-login | ||
tokenUri="https://auth.docker.io/token?service=registry.docker.io&scope=repository:${{ env.IMAGE_REPO }}:pull&scope=repository:${{ env.CRD_IMAGE_REPO }}:pull&scope=repository:${{ env.GATOR_IMAGE_REPO }}:pull" | ||
bearerToken="$(curl --silent --get $tokenUri | jq --raw-output '.token')" | ||
listUri="https://registry-1.docker.io/v2/${{ env.IMAGE_REPO }}/tags/list" | ||
authz="Authorization: Bearer $bearerToken" | ||
version_list="$(curl --silent --get -H "Accept: application/json" -H "$authz" $listUri | jq --raw-output '.')" | ||
exists=$(echo $version_list | jq --arg t ${GITHUB_SHA::7} '.tags | index($t)') | ||
if [[ $exists == null ]] | ||
then | ||
make docker-buildx-dev \ | ||
DEV_TAG=${GITHUB_SHA::7} \ | ||
PLATFORM="linux/amd64,linux/arm64,linux/arm/v7" \ | ||
OUTPUT_TYPE=type=registry \ | ||
GENERATE_ATTESTATIONS=true | ||
fi | ||
listUri="https://registry-1.docker.io/v2/${{ env.CRD_IMAGE_REPO }}/tags/list" | ||
version_list="$(curl --silent --get -H "Accept: application/json" -H "$authz" $listUri | jq --raw-output '.')" | ||
exists=$(echo $version_list | jq --arg t ${GITHUB_SHA::7} '.tags | index($t)') | ||
if [[ $exists == null ]] | ||
then | ||
make docker-buildx-crds-dev \ | ||
DEV_TAG=${GITHUB_SHA::7} | ||
PLATFORM="linux/amd64,linux/arm64,linux/arm/v7" \ | ||
OUTPUT_TYPE=type=registry \ | ||
GENERATE_ATTESTATIONS=true | ||
fi | ||
listUri="https://registry-1.docker.io/v2/${{ env.GATOR_IMAGE_REPO }}/tags/list" | ||
version_list="$(curl --silent --get -H "Accept: application/json" -H "$authz" $listUri | jq --raw-output '.')" | ||
exists=$(echo $version_list | jq --arg t ${GITHUB_SHA::7} '.tags | index($t)') | ||
if [[ $exists == null ]] | ||
then | ||
make docker-buildx-gator-dev \ | ||
DEV_TAG=${GITHUB_SHA::7} \ | ||
PLATFORM="linux/amd64,linux/arm64,linux/arm/v7" \ | ||
OUTPUT_TYPE=type=registry \ | ||
GENERATE_ATTESTATIONS=true | ||
fi | ||
env: | ||
DOCKER_USER: ${{ secrets.DOCKER_USER }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
name: release | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
IMAGE_REPO: openpolicyagent/gatekeeper | ||
CRD_IMAGE_REPO: openpolicyagent/gatekeeper-crds | ||
GATOR_IMAGE_REPO: openpolicyagent/gator | ||
|
||
jobs: | ||
tagged-release: | ||
name: "Tagged Release" | ||
runs-on: "ubuntu-22.04" | ||
permissions: | ||
contents: write | ||
if: startsWith(github.ref, 'refs/tags/v') && github.repository == 'open-policy-agent/gatekeeper' | ||
timeout-minutes: 45 | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c | ||
|
||
- name: Get tag | ||
id: get_version | ||
run: | | ||
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | ||
- name: Publish release | ||
run: | | ||
make docker-login | ||
tokenUri="https://auth.docker.io/token?service=registry.docker.io&scope=repository:${{ env.IMAGE_REPO }}:pull&scope=repository:${{ env.CRD_IMAGE_REPO }}:pull&scope=repository:${{ env.GATOR_IMAGE_REPO }}:pull" | ||
bearerToken="$(curl --silent --get $tokenUri | jq --raw-output '.token')" | ||
listUri="https://registry-1.docker.io/v2/${{ env.IMAGE_REPO }}/tags/list" | ||
authz="Authorization: Bearer $bearerToken" | ||
version_list="$(curl --silent --get -H "Accept: application/json" -H $authz $listUri | jq --raw-output '.')" | ||
exists=$(echo $version_list | jq --arg t ${TAG} '.tags | index($t)') | ||
if [[ $exists == null ]] | ||
then | ||
make docker-buildx-release \ | ||
VERSION=${TAG} \ | ||
PLATFORM="linux/amd64,linux/arm64,linux/arm/v7" \ | ||
OUTPUT_TYPE=type=registry \ | ||
GENERATE_ATTESTATIONS=true | ||
fi | ||
listUri="https://registry-1.docker.io/v2/${{ env.CRD_IMAGE_REPO }}/tags/list" | ||
version_list="$(curl --silent --get -H "Accept: application/json" -H $authz $listUri | jq --raw-output '.')" | ||
exists=$(echo $version_list | jq --arg t ${TAG} '.tags | index($t)') | ||
if [[ $exists == null ]] | ||
then | ||
make docker-buildx-crds-release \ | ||
VERSION=${TAG} \ | ||
PLATFORM="linux/amd64,linux/arm64,linux/arm/v7" \ | ||
OUTPUT_TYPE=type=registry \ | ||
GENERATE_ATTESTATIONS=true | ||
fi | ||
listUri="https://registry-1.docker.io/v2/${{ env.GATOR_IMAGE_REPO }}/tags/list" | ||
version_list="$(curl --silent --get -H "Accept: application/json" -H $authz $listUri | jq --raw-output '.')" | ||
exists=$(echo $version_list | jq --arg t ${TAG} '.tags | index($t)') | ||
if [[ $exists == null ]] | ||
then | ||
make docker-buildx-gator-release \ | ||
VERSION=${TAG} \ | ||
PLATFORM="linux/amd64,linux/arm64,linux/arm/v7" \ | ||
OUTPUT_TYPE=type=registry \ | ||
GENERATE_ATTESTATIONS=true | ||
fi | ||
env: | ||
DOCKER_USER: ${{ secrets.DOCKER_USER }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Bootstrap e2e | ||
run: | | ||
mkdir -p $GITHUB_WORKSPACE/bin | ||
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH | ||
make e2e-bootstrap | ||
- name: Verify release | ||
run: | | ||
make e2e-verify-release IMG=${{ env.IMAGE_REPO }}:${TAG} USE_LOCAL_IMG=false | ||
- name: Build gator-cli | ||
run: | | ||
build() { | ||
export GOOS="$(echo ${1} | cut -d '-' -f 1)" | ||
export GOARCH="$(echo ${1} | cut -d '-' -f 2)" | ||
FILENAME=${GITHUB_WORKSPACE}/_dist/gator-${TAG}-${GOOS}-${GOARCH} | ||
# build the binary | ||
make bin/gator-${GOOS}-${GOARCH} | ||
# rename the binary to gator | ||
tmp_dir=$(mktemp -d) | ||
cp bin/gator-${GOOS}-${GOARCH} ${tmp_dir}/gator | ||
pushd ${tmp_dir} | ||
tar -czf ${FILENAME}.tar.gz gator* | ||
popd | ||
} | ||
mkdir -p _dist | ||
for os_arch_extension in $PLATFORMS; do | ||
build ${os_arch_extension} & | ||
done | ||
wait | ||
pushd _dist | ||
# consolidate tar's sha256sum into a single file | ||
find . -type f -name '*.tar.gz' | sort | xargs sha256sum >> sha256sums.txt | ||
popd | ||
env: | ||
PLATFORMS: "linux-amd64 linux-arm64 darwin-amd64 darwin-arm64" | ||
|
||
- name: Create GitHub release | ||
uses: "marvinpinto/[email protected]" | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" | ||
prerelease: false | ||
files: | | ||
_dist/sha256sums.txt | ||
_dist/*.tar.gz | ||
- name: Publish Helm chart | ||
uses: stefanprodan/[email protected] | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
charts_dir: charts | ||
target_dir: charts | ||
linting: off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.