|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + test: |
| 10 | + uses: chainloop-dev/chainloop/.github/workflows/test.yml@main |
| 11 | + |
| 12 | + release: |
| 13 | + name: Release CLI and control-plane/artifact-cas container images |
| 14 | + needs: test |
| 15 | + runs-on: ubuntu-latest |
| 16 | + if: github.ref_type == 'tag' # Guard to make sure we are releasing once |
| 17 | + permissions: |
| 18 | + id-token: write # required to use OIDC and retrieve Google Cloud Credentials |
| 19 | + contents: write # required for goreleaser |
| 20 | + packages: write # to push container images |
| 21 | + env: |
| 22 | + CHAINLOOP_VERSION: 0.8.89 |
| 23 | + CHAINLOOP_ROBOT_ACCOUNT: ${{ secrets.CHAINLOOP_ROBOT_ACCOUNT }} |
| 24 | + CONTAINER_IMAGE_CP: ghcr.io/chainloop-dev/chainloop/control-plane:${{ github.ref_name }} |
| 25 | + CONTAINER_IMAGE_CAS: ghcr.io/chainloop-dev/chainloop/artifact-cas:${{ github.ref_name }} |
| 26 | + steps: |
| 27 | + - name: Install Cosign |
| 28 | + |
| 29 | + |
| 30 | + - name: Install Chainloop |
| 31 | + run: | |
| 32 | + curl -sfL https://chainloop.dev/install.sh | bash -s -- --version v${{ env.CHAINLOOP_VERSION }} |
| 33 | +
|
| 34 | + - name: Download jq |
| 35 | + run: | |
| 36 | + sudo wget -q https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -O /usr/local/bin/jq |
| 37 | + sudo chmod u+x /usr/local/bin/jq |
| 38 | +
|
| 39 | + - name: Checkout |
| 40 | + uses: actions/checkout@v3 |
| 41 | + with: |
| 42 | + fetch-depth: 0 |
| 43 | + |
| 44 | + - name: Initialize Attestation |
| 45 | + run: | |
| 46 | + chainloop attestation init |
| 47 | +
|
| 48 | + # TODO: remove once we move the releases and the installation script to Github |
| 49 | + - name: "Configure Google Cloud credentials" |
| 50 | + id: "auth-google" |
| 51 | + uses: "google-github-actions/auth@v0" |
| 52 | + with: |
| 53 | + token_format: "access_token" |
| 54 | + workload_identity_provider: projects/1044976554810/locations/global/workloadIdentityPools/chainloop-github-pool/providers/github-provider |
| 55 | + service_account: [email protected] |
| 56 | + |
| 57 | + - name: Docker login to Github Packages |
| 58 | + uses: docker/login-action@v2 |
| 59 | + with: |
| 60 | + registry: ghcr.io |
| 61 | + username: ${{ github.actor }} |
| 62 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + |
| 64 | + - name: Set up Go |
| 65 | + uses: actions/setup-go@v3 |
| 66 | + with: |
| 67 | + go-version: "1.20" |
| 68 | + |
| 69 | + - name: Run GoReleaser |
| 70 | + id: release |
| 71 | + uses: goreleaser/goreleaser-action@v3 |
| 72 | + with: |
| 73 | + distribution: goreleaser |
| 74 | + version: latest |
| 75 | + args: release --rm-dist |
| 76 | + env: |
| 77 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} |
| 79 | + COSIGN_KEY: ${{ secrets.COSIGN_KEY }} |
| 80 | + |
| 81 | + - uses: anchore/sbom-action@v0 |
| 82 | + with: |
| 83 | + image: ${{ env.CONTAINER_IMAGE_CP }} |
| 84 | + format: cyclonedx-json |
| 85 | + artifact-name: controlplane.cyclonedx.json |
| 86 | + output-file: /tmp/sbom.cp.cyclonedx.json |
| 87 | + |
| 88 | + - uses: anchore/sbom-action@v0 |
| 89 | + with: |
| 90 | + image: ${{ env.CONTAINER_IMAGE_CAS }} |
| 91 | + format: cyclonedx-json |
| 92 | + artifact-name: cas.cyclonedx.json |
| 93 | + output-file: /tmp/sbom.cas.cyclonedx.json |
| 94 | + |
| 95 | + - name: Add Attestation Artifacts (SBOM) |
| 96 | + run: | |
| 97 | + chainloop attestation add --name sbom-control-plane --value /tmp/sbom.cp.cyclonedx.json |
| 98 | + chainloop attestation add --name sbom-artifact-cas --value /tmp/sbom.cas.cyclonedx.json |
| 99 | +
|
| 100 | + - name: Add Attestation Artifacts (container images) |
| 101 | + run: | |
| 102 | + # Control plane image |
| 103 | + chainloop attestation add --name control-plane-image --value ${{ env.CONTAINER_IMAGE_CP }} |
| 104 | + # CAS image |
| 105 | + chainloop attestation add --name artifact-cas-image --value ${{ env.CONTAINER_IMAGE_CAS }} |
| 106 | +
|
| 107 | + - name: Add Attestation Artifacts (binaries) |
| 108 | + run: | |
| 109 | + # Binaries x86_64 |
| 110 | + # TODO: add the rest of binaries |
| 111 | + echo -n '${{ steps.release.outputs.artifacts }}' | jq -r '.[] | select(.type=="Binary" and .goos=="linux" and .goarch=="amd64") | { "name": "\(.extra.ID)-\(.goos)-\(.goarch)", "path":"\(.path)"} | @base64' | while read i; do |
| 112 | + BINARY_NAME=$(echo "${i}" | base64 --decode | jq -r ${1} .name) |
| 113 | + BINARY_PATH=$(echo "${i}" | base64 --decode | jq -r ${1} .path) |
| 114 | + chainloop attestation add --name ${BINARY_NAME} --value ${BINARY_PATH} |
| 115 | + done |
| 116 | +
|
| 117 | + - name: Finish and Record Attestation |
| 118 | + if: ${{ success() }} |
| 119 | + run: | |
| 120 | + chainloop attestation status --full |
| 121 | + chainloop attestation push --key env://CHAINLOOP_SIGNING_KEY |
| 122 | + env: |
| 123 | + CHAINLOOP_SIGNING_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} |
| 124 | + CHAINLOOP_SIGNING_KEY: ${{ secrets.COSIGN_KEY }} |
| 125 | + |
| 126 | + - name: Mark attestation as failed |
| 127 | + if: ${{ failure() }} |
| 128 | + run: | |
| 129 | + chainloop attestation reset |
| 130 | + - name: Mark attestation as cancelled |
| 131 | + if: ${{ cancelled() }} |
| 132 | + run: | |
| 133 | + chainloop attestation reset --trigger cancellation |
0 commit comments