| 
 | 1 | +name: Upload missing installers  | 
 | 2 | + | 
 | 3 | +on: [push]  | 
 | 4 | + | 
 | 5 | +jobs:  | 
 | 6 | +  upload-missing:  | 
 | 7 | +    runs-on: ubuntu-latest  | 
 | 8 | +    permissions:  | 
 | 9 | +      contents: write  | 
 | 10 | +    steps:  | 
 | 11 | +      - uses: actions/create-github-app-token@v1  | 
 | 12 | +        id: token  | 
 | 13 | +        with:  | 
 | 14 | +          app-id: ${{ secrets.GH_APP_ID }}  | 
 | 15 | +          private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}  | 
 | 16 | +          owner: ${{ github.repository_owner }}  | 
 | 17 | +          repositories: |  | 
 | 18 | +            git-snapshots  | 
 | 19 | +            git-for-windows-automation  | 
 | 20 | +      - name: backfill missing installers  | 
 | 21 | +        env:  | 
 | 22 | +          GH_TOKEN: ${{ steps.token.outputs.token }}  | 
 | 23 | +        run: |  | 
 | 24 | +          set -ex  | 
 | 25 | +          for logs_url in $(gh api \  | 
 | 26 | +            repos/git-for-windows/git-for-windows-automation/actions/workflows/upload-snapshot.yml/runs \  | 
 | 27 | +            --jq '.workflow_runs[].logs_url')  | 
 | 28 | +          do  | 
 | 29 | +            gh api "${logs_url#https://api.github.com/}" >logs.zip  | 
 | 30 | +            unzip -p logs.zip upload-snapshot/\*_download\ remaining\ artifacts.txt >log.txt  | 
 | 31 | +            test -s log.txt  | 
 | 32 | +            sed -n \  | 
 | 33 | +              's:.*   "\(installer\|portable\)\(.*\)/\(Portable\)\?\(.*[^z]\)\(\.7z\)\?\(\.exe\).*:installer\2 \4\6:p' \  | 
 | 34 | +              <log.txt >potentials.txt  | 
 | 35 | +            test -s potentials.txt  | 
 | 36 | +            sort <potentials.txt >sorted.txt  | 
 | 37 | +            uniq -u <sorted.txt >list.txt  | 
 | 38 | +
  | 
 | 39 | +            test -s list.txt || continue  | 
 | 40 | +
  | 
 | 41 | +            tag_name="$(sed -n '1s/.* Git-\(.*\)-\(arm64\|64-bit\|32-bit\)\.exe.*/\1/p' list.txt)"  | 
 | 42 | +
  | 
 | 43 | +            sed -n 's/.* \(I686\|X86_64\|AARCH64\)\(_WORKFLOW_RUN_ID\): \([0-9]*\)$/\1\2=\3/p' <log.txt >run-ids.txt  | 
 | 44 | +            test 3 = $(wc -l <run-ids.txt)  | 
 | 45 | +            eval "$(tr A-Z a-z <run-ids.txt)"  | 
 | 46 | +
  | 
 | 47 | +            while read asset file  | 
 | 48 | +            do  | 
 | 49 | +              arch=${asset#*-} &&  | 
 | 50 | +              eval run_id=\$${arch}_workflow_run_id &&  | 
 | 51 | +              echo "Downloading $asset from $run_id" &&  | 
 | 52 | +              rm -f package-versions.txt sha256sums.txt &&  | 
 | 53 | +              ls -lart &&  | 
 | 54 | +              gh -R git-for-windows/git-for-windows-automation run download $run_id --name "$asset" ||  | 
 | 55 | +              exit 1  | 
 | 56 | +            done <list.txt  | 
 | 57 | +
  | 
 | 58 | +            files="$(cut -d ' ' -f 2 <list.txt)"  | 
 | 59 | +
  | 
 | 60 | +            gh release upload -R ${{ github.repository }} --title "$date" "$tag_name" $files ||  | 
 | 61 | +            exit 1  | 
 | 62 | +          done  | 
0 commit comments