Skip to content

Commit f81a43e

Browse files
authored
Revert "feat(workflows): Integrate GitHub Release reusable workflow (#851) (#857)
Signed-off-by: Javier Rodriguez <[email protected]>
1 parent 070c5aa commit f81a43e

File tree

1 file changed

+87
-7
lines changed

1 file changed

+87
-7
lines changed

.github/workflows/release.yaml

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,100 @@ name: Release
22

33
on:
44
release:
5-
types: [published]
65

76
permissions:
87
contents: write
98

109
jobs:
11-
release:
12-
name: Attest GitHub Release
13-
uses: chainloop-dev/labs/.github/workflows/chainloop_github_release.yml@417bad33ca08beaa785ae6a6b933406cd7b935cb
10+
# This reusable workflow inspects if the given workflow_name exists on Chainloop. If the Workflow does not exist
11+
# it will create one with an empty contract ready for operators to be filled. Otherwise, if found, it will just
12+
# be ignored and the process will continue. For this to work it's using a pre-created API Token
13+
onboard_workflow:
14+
name: Onboard Chainloop Workflow
15+
uses: chainloop-dev/labs/.github/workflows/chainloop_onboard.yml@4173e015dbd5dc2a8802555c268da63d57bbe576
1416
with:
1517
project: "chainloop"
1618
workflow_name: "chainloop-vault-release"
17-
additional_materials: "ghcr.io/chainloop-dev/chainloop/control-plane:${{ github.ref_name }},ghcr.io/chainloop-dev/chainloop/artifact-cas:${{ github.ref_name }},ghcr.io/chainloop-dev/chainloop/cli:${{ github.ref_name }}"
1819
secrets:
1920
api_token: ${{ secrets.CHAINLOOP_API_TOKEN }}
20-
cosign_key: ${{ secrets.COSIGN_KEY }}
21-
cosign_password: ${{ secrets.COSIGN_PASSWORD }}
21+
22+
release:
23+
name: Record release from GitHub
24+
runs-on: ubuntu-latest
25+
needs: onboard_workflow
26+
permissions:
27+
packages: write
28+
env:
29+
CHAINLOOP_VERSION: 0.89.0
30+
CHAINLOOP_TOKEN: ${{ secrets.CHAINLOOP_API_TOKEN }}
31+
CHAINLOOP_WORKFLOW_NAME: ${{ needs.onboard_workflow.outputs.workflow_name }}
32+
GH_TOKEN: ${{ github.token }}
33+
steps:
34+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
35+
36+
- name: Install Chainloop
37+
run: |
38+
curl -sfL https://raw.githubusercontent.com/chainloop-dev/chainloop/01ad13af08950b7bfbc83569bea207aeb4e1a285/docs/static/install.sh | bash -s -- --version v${{ env.CHAINLOOP_VERSION }}
39+
40+
- name: Initialize Attestation
41+
run: |
42+
chainloop attestation init --workflow-name ${CHAINLOOP_WORKFLOW_NAME}
43+
44+
- name: Attest all assets
45+
run: |
46+
tag=$(echo -n ${{github.ref}} | cut -d / -f3)
47+
gh release download $tag -D /tmp/github-release
48+
for entry in $(ls /tmp/github-release); do
49+
chainloop attestation add --value "/tmp/github-release/$entry"
50+
done
51+
52+
# Include source code
53+
version=$(echo -n $tag | sed 's/v//g')
54+
gh release download $tag -A tar.gz -D /tmp
55+
chainloop attestation add --value "/tmp/chainloop-$version.tar.gz"
56+
57+
# Include control-plane image
58+
chainloop attestation add --value "ghcr.io/chainloop-dev/chainloop/control-plane:$tag"
59+
60+
# Include cas image
61+
chainloop attestation add --value "ghcr.io/chainloop-dev/chainloop/artifact-cas:$tag"
62+
63+
# Include cli image
64+
chainloop attestation add --value "ghcr.io/chainloop-dev/chainloop/cli:$tag"
65+
66+
- name: Finish and Record Attestation
67+
id: attestation-push
68+
if: ${{ success() }}
69+
run: |
70+
chainloop attestation status --full
71+
attestation_sha=$(chainloop attestation push --key env://CHAINLOOP_SIGNING_KEY -o json | jq -r '.digest')
72+
echo "attestation_sha=$attestation_sha" >> $GITHUB_OUTPUT
73+
env:
74+
CHAINLOOP_SIGNING_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
75+
CHAINLOOP_SIGNING_KEY: ${{ secrets.COSIGN_KEY }}
76+
77+
- name: Mark attestation as failed
78+
if: ${{ failure() }}
79+
run: |
80+
chainloop attestation reset
81+
82+
- name: Mark attestation as cancelled
83+
if: ${{ cancelled() }}
84+
run: |
85+
chainloop attestation reset --trigger cancellation
86+
87+
- name: Add attestation link to release notes
88+
if: ${{ success() }}
89+
run: |
90+
chainloop_release_url="## Chainloop Attestation"$'\n'"[View the attestation of this release](https://app.chainloop.dev/attestation/${{ steps.attestation-push.outputs.attestation_sha }})"
91+
current_notes=$(gh release view ${{ github.ref_name }} --json body -q '.body')
92+
93+
if echo "$current_notes" | grep -q "## Chainloop Attestation"; then
94+
# Replace the existing Chainloop Attestation section with the new URL
95+
modified_notes=$(echo "$current_notes" | sed -E "s|## Chainloop Attestation[^\n]*\n\[View the attestation of this release\]\(https://app\.chainloop\.dev/attestation/[^\)]*\)|$chainloop_release_url|")
96+
else
97+
# Add the Chainloop Attestation section to the top
98+
modified_notes="$chainloop_release_url"$'\n\n'"$current_notes"
99+
fi
100+
101+
gh release edit ${{ github.ref_name }} -n "$modified_notes"

0 commit comments

Comments
 (0)