forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: generate attestations during a release (argoproj#12484)
* chore: generate attestations during a release Signed-off-by: Justin Marquis <[email protected]> enable attestation for dockerhub Signed-off-by: Justin Marquis <[email protected]> release assests no longer compressed Signed-off-by: Justin Marquis <[email protected]> renamed attestion for cli Signed-off-by: Justin Marquis <[email protected]> updated docs to reflect non compressed cli binaries Signed-off-by: Justin Marquis <[email protected]> use quay username for provenance generator Signed-off-by: Justin Marquis <[email protected]> add check for TARGET_VERSION Signed-off-by: Justin Marquis <[email protected]> fixed typo Signed-off-by: Justin Marquis <[email protected]> updated go to 1.19 Signed-off-by: Justin Marquis <[email protected]> update cosign and slsa-github-generators Signed-off-by: Justin Marquis <[email protected]> update docs for cosignv2.0.0 Signed-off-by: Justin Marquis <[email protected]> remove docker registry from release Signed-off-by: Justin Marquis <[email protected]> * negate tags for v2.4,v2.5,v2.6 for release Signed-off-by: Justin Marquis <[email protected]> * bug fix for release notes Signed-off-by: Justin Marquis <[email protected]> --------- Signed-off-by: Justin Marquis <[email protected]> Signed-off-by: Michael Crenshaw <[email protected]> Co-authored-by: Michael Crenshaw <[email protected]>
- Loading branch information
1 parent
70ac450
commit 17b8180
Showing
10 changed files
with
832 additions
and
576 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Workflows | ||
|
||
| Workflow | Description | | ||
|--------------------|----------------------------------------------------------------| | ||
| ci-build.yaml | Build, lint, test, codegen, build-ui, analyze, e2e-test | | ||
| codeql.yaml | CodeQL analysis | | ||
| image-reuse.yaml | Build, push, and Sign container images | | ||
| image.yaml | Build container image for PR's & publish for push events | | ||
| pr-title-check.yaml| Lint PR for semantic information | | ||
| init-release.yaml | Build manifests and version then create a PR for release branch| | ||
| release.yaml | Build images, cli-binaries, provenances, and post actions | | ||
| update-snyk.yaml | Scheduled snyk reports | | ||
|
||
# Reusable workflows | ||
|
||
## image-reuse.yaml | ||
|
||
- The resuable workflow can be used to publish or build images with multiple container registries(Quay,GHCR, dockerhub), and then sign them with cosign when an image is published. | ||
- A GO version `must` be specified e.g. 1.19 | ||
- The image name for each registry *must* contain the tag. Note: multiple tags are allowed for each registry using a CSV type. | ||
- Multiple platforms can be specified e.g. linux/amd64,linux/arm64 | ||
- Images are not published by default. A boolean value must be set to `true` to push images. | ||
- An optional target can be specified. | ||
|
||
| Inputs | Description | Type | Required | Defaults | | ||
|-------------------|-------------------------------------|-------------|----------|-----------------| | ||
| go-version | Version of Go to be used | string | true | none | | ||
| quay_image_name | Full image name and tag | CSV, string | false | none | | ||
| ghcr_image_name | Full image name and tag | CSV, string | false | none | | ||
| docker_image_name | Full image name and tag | CSV, string | false | none | | ||
| platforms | Platforms to build (linux/amd64) | CSV, string | false | linux/amd64 | | ||
| push | Whether to push image/s to registry | boolean | false | false | | ||
| target | Target build stage | string | false | none | | ||
|
||
| Outputs | Description | Type | | ||
|-------------|------------------------------------------|-------| | ||
|image-digest | Image digest of image container created | string| | ||
|
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,153 @@ | ||
name: Publish and Sign Container Image | ||
on: | ||
workflow_call: | ||
inputs: | ||
go-version: | ||
required: true | ||
type: string | ||
quay_image_name: | ||
required: false | ||
type: string | ||
ghcr_image_name: | ||
required: false | ||
type: string | ||
docker_image_name: | ||
required: false | ||
type: string | ||
platforms: | ||
required: true | ||
type: string | ||
default: linux/amd64 | ||
push: | ||
required: true | ||
type: boolean | ||
default: false | ||
target: | ||
required: false | ||
type: string | ||
|
||
secrets: | ||
quay_username: | ||
required: false | ||
quay_password: | ||
required: false | ||
ghcr_username: | ||
required: false | ||
ghcr_password: | ||
required: false | ||
docker_username: | ||
required: false | ||
docker_password: | ||
required: false | ||
|
||
outputs: | ||
image-digest: | ||
description: "sha256 digest of container image" | ||
value: ${{ jobs.publish.outputs.image-digest }} | ||
|
||
permissions: {} | ||
|
||
jobs: | ||
publish: | ||
permissions: | ||
contents: read | ||
packages: write # Used to push images to `ghcr.io` if used. | ||
id-token: write # Needed to create an OIDC token for keyless signing | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
image-digest: ${{ steps.image.outputs.digest }} | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.3.0 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
if: ${{ github.ref_type == 'tag'}} | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
if: ${{ github.ref_type != 'tag'}} | ||
|
||
- name: Setup Golang | ||
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 | ||
with: | ||
go-version: ${{ inputs.go-version }} | ||
|
||
- name: Install cosign | ||
uses: sigstore/cosign-installer@c3667d99424e7e6047999fb6246c0da843953c65 # v3.0.1 | ||
with: | ||
cosign-release: 'v2.0.0' | ||
|
||
- uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0 | ||
- uses: docker/setup-buildx-action@15c905b16b06416d2086efa066dd8e3a35cc7f98 # v2.4.0 | ||
|
||
- name: Setup tags for container image as a CSV type | ||
run: | | ||
IMAGE_TAGS=$(for str in \ | ||
${{ inputs.quay_image_name }} \ | ||
${{ inputs.ghcr_image_name }} \ | ||
${{ inputs.docker_image_name}}; do | ||
echo -n "${str}",;done | sed 's/,$//') | ||
echo $IMAGE_TAGS | ||
echo "TAGS=$IMAGE_TAGS" >> $GITHUB_ENV | ||
- name: Setup image namespace for signing, strip off the tag | ||
run: | | ||
TAGS=$(for tag in \ | ||
${{ inputs.quay_image_name }} \ | ||
${{ inputs.ghcr_image_name }} \ | ||
${{ inputs.docker_image_name}}; do | ||
echo -n "${tag}" | awk -F ":" '{print $1}' -;done) | ||
echo $TAGS | ||
echo 'SIGNING_TAGS<<EOF' >> $GITHUB_ENV | ||
echo $TAGS >> $GITHUB_ENV | ||
echo 'EOF' >> $GITHUB_ENV | ||
- name: Login to Quay.io | ||
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0 | ||
with: | ||
registry: quay.io | ||
username: ${{ secrets.quay_username }} | ||
password: ${{ secrets.quay_password }} | ||
if: ${{ inputs.quay_image_name && inputs.push }} | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ secrets.ghcr_username }} | ||
password: ${{ secrets.ghcr_password }} | ||
if: ${{ inputs.ghcr_image_name && inputs.push }} | ||
|
||
- name: Login to dockerhub Container Registry | ||
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0 | ||
with: | ||
username: ${{ secrets.docker_username }} | ||
password: ${{ secrets.docker_password }} | ||
if: ${{ inputs.docker_image_name && inputs.push }} | ||
|
||
- name: Build and push container image | ||
id: image | ||
uses: docker/build-push-action@37abcedcc1da61a57767b7588cb9d03eb57e28b3 #v3.3.0 | ||
with: | ||
context: . | ||
platforms: ${{ inputs.platforms }} | ||
push: ${{ inputs.push }} | ||
tags: ${{ env.TAGS }} | ||
target: ${{ inputs.target }} | ||
provenance: false | ||
sbom: false | ||
|
||
- name: Sign container images | ||
run: | | ||
for signing_tag in $SIGNING_TAGS; do | ||
cosign sign \ | ||
-a "repo=${{ github.repository }}" \ | ||
-a "workflow=${{ github.workflow }}" \ | ||
-a "sha=${{ github.sha }}" \ | ||
-y \ | ||
"$signing_tag"@${{ steps.image.outputs.digest }} | ||
done | ||
if: ${{ inputs.push }} |
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 |
---|---|---|
|
@@ -9,97 +9,105 @@ on: | |
- master | ||
types: [ labeled, unlabeled, opened, synchronize, reopened ] | ||
|
||
env: | ||
GOLANG_VERSION: '1.19' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: read | ||
permissions: {} | ||
|
||
jobs: | ||
publish: | ||
set-vars: | ||
permissions: | ||
contents: write # for git to push upgrade commit if not already deployed | ||
packages: write # for pushing packages to GHCR, which is used by cd.apps.argoproj.io to avoid polluting Quay with tags | ||
contents: read | ||
if: github.repository == 'argoproj/argo-cd' | ||
runs-on: ubuntu-22.04 | ||
env: | ||
GOPATH: /home/runner/work/argo-cd/argo-cd | ||
outputs: | ||
image-tag: ${{ steps.image.outputs.tag}} | ||
platforms: ${{ steps.platforms.outputs.platforms }} | ||
steps: | ||
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0 | ||
with: | ||
go-version: ${{ env.GOLANG_VERSION }} | ||
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0 | ||
with: | ||
path: src/github.com/argoproj/argo-cd | ||
|
||
# get image tag | ||
- run: echo "tag=$(cat ./VERSION)-${GITHUB_SHA::8}" >> $GITHUB_OUTPUT | ||
working-directory: ./src/github.com/argoproj/argo-cd | ||
- name: Set image tag for ghcr | ||
run: echo "tag=$(cat ./VERSION)-${GITHUB_SHA::8}" >> $GITHUB_OUTPUT | ||
id: image | ||
|
||
# login | ||
- run: | | ||
docker login ghcr.io --username $USERNAME --password-stdin <<< "$PASSWORD" | ||
docker login quay.io --username "$DOCKER_USERNAME" --password-stdin <<< "$DOCKER_TOKEN" | ||
if: github.event_name == 'push' | ||
env: | ||
USERNAME: ${{ github.actor }} | ||
PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||
DOCKER_USERNAME: ${{ secrets.RELEASE_QUAY_USERNAME }} | ||
DOCKER_TOKEN: ${{ secrets.RELEASE_QUAY_TOKEN }} | ||
# build | ||
- uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0 | ||
- uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0 | ||
- run: | | ||
- name: Determine image platforms to use | ||
id: platforms | ||
run: | | ||
IMAGE_PLATFORMS=linux/amd64 | ||
if [[ "${{ github.event_name }}" == "push" || "${{ contains(github.event.pull_request.labels.*.name, 'test-arm-image') }}" == "true" ]] | ||
if [[ "${{ github.event_name }}" == "push" || "${{ contains(github.event.pull_request.labels.*.name, 'test-multi-image') }}" == "true" ]] | ||
then | ||
IMAGE_PLATFORMS=linux/amd64,linux/arm64,linux/s390x,linux/ppc64le | ||
fi | ||
echo "Building image for platforms: $IMAGE_PLATFORMS" | ||
docker buildx build --platform $IMAGE_PLATFORMS --sbom=false --provenance=false --push="${{ github.event_name == 'push' }}" \ | ||
-t ghcr.io/argoproj/argo-cd/argocd:${{ steps.image.outputs.tag }} \ | ||
-t quay.io/argoproj/argocd:latest . | ||
working-directory: ./src/github.com/argoproj/argo-cd | ||
# sign container images | ||
- name: Install cosign | ||
uses: sigstore/cosign-installer@c3667d99424e7e6047999fb6246c0da843953c65 # v3.0.1 | ||
with: | ||
cosign-release: 'v1.13.1' | ||
echo "platforms=$IMAGE_PLATFORMS" >> $GITHUB_OUTPUT | ||
- name: Install crane to get digest of image | ||
uses: imjasonh/setup-crane@00c9e93efa4e1138c9a7a5c594acd6c75a2fbf0c | ||
build-only: | ||
needs: [set-vars] | ||
permissions: | ||
contents: read | ||
packages: write # for pushing packages to GHCR, which is used by cd.apps.argoproj.io to avoid polluting Quay with tags | ||
id-token: write # for creating OIDC tokens for signing. | ||
if: ${{ github.repository == 'argoproj/argo-cd' && github.event_name != 'push' }} | ||
uses: ./.github/workflows/image-reuse.yaml | ||
with: | ||
# Note: cannot use env variables to set go-version (https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations) | ||
go-version: 1.19 | ||
platforms: ${{ needs.set-vars.outputs.platforms }} | ||
push: false | ||
|
||
- name: Get digest of image | ||
run: | | ||
echo "IMAGE_DIGEST=$(crane digest quay.io/argoproj/argocd:latest)" >> $GITHUB_ENV | ||
build-and-publish: | ||
needs: [set-vars] | ||
permissions: | ||
contents: read | ||
packages: write # for pushing packages to GHCR, which is used by cd.apps.argoproj.io to avoid polluting Quay with tags | ||
id-token: write # for creating OIDC tokens for signing. | ||
if: ${{ github.repository == 'argoproj/argo-cd' && github.event_name == 'push' }} | ||
uses: ./.github/workflows/image-reuse.yaml | ||
with: | ||
quay_image_name: quay.io/argoproj/argocd:latest | ||
ghcr_image_name: ghcr.io/argoproj/argo-cd:${{ needs.set-vars.outputs.image-tag }} | ||
# Note: cannot use env variables to set go-version (https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations) | ||
go-version: 1.19 | ||
platforms: ${{ needs.set-vars.outputs.platforms }} | ||
push: true | ||
secrets: | ||
quay_username: ${{ secrets.RELEASE_QUAY_USERNAME }} | ||
quay_password: ${{ secrets.RELEASE_QUAY_TOKEN }} | ||
ghcr_username: ${{ github.actor }} | ||
ghcr_password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Sign Argo CD latest image | ||
run: | | ||
cosign sign --key env://COSIGN_PRIVATE_KEY quay.io/argoproj/argocd@${{ env.IMAGE_DIGEST }} | ||
# Displays the public key to share. | ||
cosign public-key --key env://COSIGN_PRIVATE_KEY | ||
env: | ||
COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY}} | ||
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}} | ||
if: ${{ github.event_name == 'push' }} | ||
build-and-publish-provenance: | ||
needs: [build-and-publish] | ||
permissions: | ||
actions: read # for detecting the Github Actions environment. | ||
id-token: write # for creating OIDC tokens for signing. | ||
packages: write # for uploading attestations. (https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/container/README.md#known-issues) | ||
if: ${{ github.repository == 'argoproj/argo-cd' && github.event_name != 'push' }} | ||
# Must be refernced by a tag. https://github.com/slsa-framework/slsa-github-generator/blob/main/internal/builders/container/README.md#referencing-the-slsa-generator | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] | ||
with: | ||
image: quay.io/argoproj/argocd | ||
digest: ${{ needs.build-and-publish.outputs.image-digest }} | ||
secrets: | ||
registry-username: ${{ secrets.RELEASE_QUAY_USERNAME }} | ||
registry-password: ${{ secrets.RELEASE_QUAY_TOKEN }} | ||
|
||
# deploy | ||
Deploy: | ||
needs: [build-and-publish] | ||
permissions: | ||
contents: write # for git to push upgrade commit if not already deployed | ||
packages: write # for pushing packages to GHCR, which is used by cd.apps.argoproj.io to avoid polluting Quay with tags | ||
if: ${{ github.repository == 'argoproj/argo-cd' && github.event_name == 'push' }} | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | ||
- run: git clone "https://[email protected]/argoproj/argoproj-deployments" | ||
if: github.event_name == 'push' | ||
env: | ||
TOKEN: ${{ secrets.TOKEN }} | ||
- run: | | ||
docker run -u $(id -u):$(id -g) -v $(pwd):/src -w /src --rm -t ghcr.io/argoproj/argo-cd/argocd:${{ steps.image.outputs.tag }} kustomize edit set image quay.io/argoproj/argocd=ghcr.io/argoproj/argo-cd/argocd:${{ steps.image.outputs.tag }} | ||
docker run -u $(id -u):$(id -g) -v $(pwd):/src -w /src --rm -t ghcr.io/argoproj/argo-cd/argocd:${{ needs.set-vars.outputs.image-tag }} kustomize edit set image quay.io/argoproj/argocd=ghcr.io/argoproj/argo-cd/argocd:${{ needs.set-vars.outputs.image-tag }} | ||
git config --global user.email '[email protected]' | ||
git config --global user.name 'CI' | ||
git diff --exit-code && echo 'Already deployed' || (git commit -am 'Upgrade argocd to ${{ steps.image.outputs.tag }}' && git push) | ||
if: github.event_name == 'push' | ||
git diff --exit-code && echo 'Already deployed' || (git commit -am 'Upgrade argocd to ${{ needs.set-vars.outputs.image-tag }}' && git push) | ||
working-directory: argoproj-deployments/argocd | ||
# TODO: clean up old images once github supports it: https://github.community/t5/How-to-use-Git-and-GitHub/Deleting-images-from-GitHub-Package-Registry/m-p/41202/thread-id/9811 |
Oops, something went wrong.