forked from vercel/pkg-fetch
-
-
Notifications
You must be signed in to change notification settings - Fork 13
126 lines (112 loc) · 4.42 KB
/
build-all.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Build All Latest Assets
on:
workflow_dispatch:
inputs:
newRelease:
description: 'Upload assets to new draft release?'
default: false
type: boolean
jobs:
build-alpine:
uses: ./.github/workflows/build-alpine.yml
build-linux:
uses: ./.github/workflows/build-linux.yml
build-linuxstatic:
uses: ./.github/workflows/build-linuxstatic.yml
build-macos:
uses: ./.github/workflows/build-macos.yml
build-windows:
uses: ./.github/workflows/build-windows.yml
collect-artifacts:
permissions:
contents: write
runs-on: ubuntu-latest
needs: [build-alpine, build-linux, build-linuxstatic, build-macos, build-windows]
steps:
- run: echo Is making new release? '${{ inputs.newRelease }}'
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: downloaded-artifacts
- name: Get previous release tag
env:
GITHUB_TOKEN: ${{ github.token }}
id: get_previous_release
run: |
PREV_RELEASE=$(gh release list --limit 1 --exclude-drafts --exclude-pre-releases | cut -f3)
echo "Using release ${PREV_RELEASE}"
echo "prev_release=${PREV_RELEASE}" >> $GITHUB_OUTPUT
- name: Get previously released artifacts
if: ${{ inputs.newRelease }}
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
gh release download ${{ steps.get_previous_release.outputs.prev_release }} --dir release-artifacts
- name: Create artifact folders
run: mkdir artifact-binaries && mkdir artifact-shas
- name: Copy previous release artifacts to artifact folders
if: ${{ inputs.newRelease }}
run: |
pushd release-artifacts
pwd
ls -la
mv *.sha256sum ../artifact-shas/.
mv * ../artifact-binaries/.
popd
- name: Copy current workflow artifacts to artifact folders
run: |
pushd downloaded-artifacts
pwd
ls -la
for f in $(ls); do
mv $f/*.sha256sum ../artifact-shas/.
mv $f/* ../artifact-binaries/.
done
popd
- name: Check SHAs
run: |
cd artifact-binaries
ls ../artifact-shas/*.sha256sum | xargs sha256sum --check
- name: Generate SHA summary
id: generate_sha_file
run: |
echo "---" >> $GITHUB_STEP_SUMMARY
echo "Update $(date -u +%F) $(date -u +%T) GMT/UTC" >> $GITHUB_STEP_SUMMARY
echo "### SHAs of produced and carried forward binaries by this workflow" >> $GITHUB_STEP_SUMMARY
echo " - $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
sha_output_file=${GITHUB_SHA}_${RANDOM}_shas.txt
echo "sha_output_file=${sha_output_file}" >> $GITHUB_OUTPUT
cat artifact-shas/*.sha256sum > ${sha_output_file}
cat artifact-shas/*.sha256sum >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
# Get a random string of characters to represent the EOF delimiter
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "sha_summary<<$EOF" >> $GITHUB_ENV
cat $GITHUB_STEP_SUMMARY >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Determine release tag to upload assets to and draft type
run: |
if [[ "${{ inputs.newRelease }}" == "false" ]]; then
echo "use_release_tag=${{ steps.get_previous_release.outputs.prev_release }}" >> $GITHUB_ENV
echo "create_draft=false" >> $GITHUB_ENV
else
echo "use_release_tag=draft_release_${{ github.sha }}" >> $GITHUB_ENV
echo "create_draft=true" >> $GITHUB_ENV
fi
- name: Add binaries to release
id: create_release
uses: softprops/action-gh-release@d4e8205d7e959a9107da6396278b2f1f07af0f9b
with:
token: ${{ github.token }}
draft: ${{ env.create_draft }}
tag_name: ${{ env.use_release_tag }}
files: |
artifact-shas/*
artifact-binaries/*
body: "${{ env.sha_summary }}"
generate_release_notes: true
append_body: true
- name: Add release url to summary
run: echo "Release created/updated at ${{ steps.create_release.outputs.url }}" >> $GITHUB_STEP_SUMMARY