2024-01-12 19:22:06 +00:00
|
|
|
name: Copy assets to the new release
|
|
|
|
|
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types: published
|
|
|
|
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
release:
|
2024-05-30 06:35:32 +01:00
|
|
|
name: Copy release assets
|
2024-01-12 19:22:06 +00:00
|
|
|
runs-on: ubuntu-latest
|
2024-05-30 06:35:32 +01:00
|
|
|
permissions:
|
|
|
|
contents: write # to upload assets to releases
|
|
|
|
attestations: write # to upload assets attestation for build provenance
|
|
|
|
id-token: write # grant additional permission to attestation action to mint the OIDC token permission
|
2024-01-12 19:22:06 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2024-05-30 06:35:32 +01:00
|
|
|
- name: Set tag names
|
2024-01-12 19:22:06 +00:00
|
|
|
run: |
|
2024-05-30 06:35:32 +01:00
|
|
|
echo "LATEST=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
|
|
|
|
echo "PREVIOUS=$(git describe --tags --abbrev=0 $(git describe --tags --abbrev=0)^)" >> $GITHUB_ENV
|
2024-01-12 19:22:06 +00:00
|
|
|
|
2024-05-30 06:35:32 +01:00
|
|
|
- name: Download assets
|
|
|
|
run: |
|
2024-01-12 19:22:06 +00:00
|
|
|
mkdir release-assets && cd release-assets
|
|
|
|
gh release download "$PREVIOUS"
|
2024-05-30 06:35:32 +01:00
|
|
|
|
|
|
|
- name: Construct subject-path for attest
|
|
|
|
if: github.repository == 'tldr-pages/tldr'
|
|
|
|
id: construct-subject-path
|
|
|
|
run: |
|
|
|
|
zip_files=$(find release-assets -name '*.zip' -printf '%p,')
|
|
|
|
pdf_files=$(find release-assets -name '*.pdf' -printf '%p,')
|
|
|
|
subject_path="${zip_files::-1},${pdf_files::-1},release-assets/tldr.sha256sums"
|
|
|
|
echo "subject_path=$subject_path" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Attest copied assets
|
|
|
|
if: github.repository == 'tldr-pages/tldr'
|
|
|
|
id: attest
|
|
|
|
uses: actions/attest-build-provenance@v1
|
|
|
|
with:
|
|
|
|
subject-path: ${{ env.subject_path }}
|
|
|
|
|
|
|
|
- name: Upload assets
|
|
|
|
if: github.repository == 'tldr-pages/tldr'
|
|
|
|
working-directory: release-assets
|
|
|
|
run: gh release upload "$LATEST" -- *
|