|
| 1 | +name: Upload Release Artifact |
| 2 | +description: >- |
| 3 | + Upload release artifact along with an attestation. The action assumes that |
| 4 | + the llvm-project repository has already been checked out. |
| 5 | +inputs: |
| 6 | + files: |
| 7 | + description: >- |
| 8 | + Files to be uploaded. This can contain bash wildcards. |
| 9 | + required: true |
| 10 | + release-version: |
| 11 | + description: >- |
| 12 | + The release where the artifact will be attached. |
| 13 | + required: true |
| 14 | + upload: |
| 15 | + description: >- |
| 16 | + Whether or not to upload the file and attestation to the release. If this |
| 17 | + is set to false, then the atteastion will still be generated and attached as |
| 18 | + an artifact to the workflow, but won't be uploaded to the release. |
| 19 | + default: true |
| 20 | + user-token: |
| 21 | + description: >- |
| 22 | + Token with premissions to read llvm teams that is used to ensure that |
| 23 | + the person who triggred the action has permission to upload artifacts. |
| 24 | + This is required if upload is true. |
| 25 | + requred: false |
| 26 | + attestation-name: |
| 27 | + description: >- |
| 28 | + This will be used for the artifact name that is attached to the workflow and |
| 29 | + will be used as the basename for the attestation file which will be called |
| 30 | + $attestation-name.jsonl. If this is not set, it will default |
| 31 | + to the falue of `files`. |
| 32 | + required: false |
| 33 | + |
| 34 | + |
| 35 | +runs: |
| 36 | + using: "composite" |
| 37 | + steps: |
| 38 | + - name: Collect Variables |
| 39 | + id: vars |
| 40 | + shell: bash |
| 41 | + env: |
| 42 | + INPUTS_ATTESTATION_NAME: ${{ inputs.attestation-name }} |
| 43 | + INPUTS_FILES: ${{ inputs.files }} |
| 44 | + run: | |
| 45 | + if [ -z "$INPUTS_ATTESTATION_NAME" ]; then |
| 46 | + name="$INPUTS_FILES" |
| 47 | + else |
| 48 | + name="$INPUTS_ATTESTATION_NAME" |
| 49 | + fi |
| 50 | + echo "attestation-name=$name" >> $GITHUB_OUTPUT |
| 51 | + - name: Attest Build Provenance |
| 52 | + id: provenance |
| 53 | + uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0 |
| 54 | + with: |
| 55 | + subject-path: ${{ inputs.files }} |
| 56 | + |
| 57 | + - name: Rename attestation file |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + mv ${{ steps.provenance.outputs.bundle-path }} ${{ steps.vars.outputs.attestation-name }}.jsonl |
| 61 | +
|
| 62 | + - name: Upload Build Provenance |
| 63 | + uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 |
| 64 | + with: |
| 65 | + name: ${{ steps.vars.outputs.attestation-name }} |
| 66 | + path: | |
| 67 | + ${{ inputs.files }} |
| 68 | + ${{ steps.vars.outputs.attestation-name }}.jsonl |
| 69 | +
|
| 70 | + - name: Install Python Requirements |
| 71 | + if: inputs.upload == 'true' |
| 72 | + shell: bash |
| 73 | + run: | |
| 74 | + pip install --require-hashes -r ./llvm/utils/git/requirements.txt |
| 75 | +
|
| 76 | + - name: Check Permissions |
| 77 | + if: inputs.upload == 'true' |
| 78 | + env: |
| 79 | + GITHUB_TOKEN: ${{ github.token }} |
| 80 | + USER_TOKEN: ${{ inputs.user-token }} |
| 81 | + shell: bash |
| 82 | + run: | |
| 83 | + ./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user "$GITHUB_ACTOR" --user-token "$USER_TOKEN" check-permissions |
| 84 | + - name: Upload Release |
| 85 | + shell: bash |
| 86 | + if: inputs.upload == 'true' |
| 87 | + run: | |
| 88 | + ./llvm/utils/release/github-upload-release.py \ |
| 89 | + --token ${{ github.token }} \ |
| 90 | + --release ${{ inputs.release-version }} \ |
| 91 | + upload \ |
| 92 | + --files ${{ inputs.files }} ${{ steps.vars.outputs.attestation-name}}.jsonl |
0 commit comments