-
Notifications
You must be signed in to change notification settings - Fork 52
69 lines (66 loc) · 2.74 KB
/
prerelease.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
name: prerelease
on:
workflow_dispatch:
inputs:
sha:
description: "SHA (leave blank for HEAD)"
required: false
env:
ACTIONS_API_URL: https://api.github.com/repos/${GITHUB_REPOSITORY}/actions
VERSION_START_SHA: e87be0e3cfa66411976ca04a72dd29e36c483966
jobs:
version:
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.sha.outputs.sha }}
tag: ${{ steps.version.outputs.tag }}
steps:
- id: sha
run: |
SHA=$(if [[ "${{ github.event.inputs.sha }}" ]]; then echo "${{ github.event.inputs.sha }}"; else echo "${GITHUB_SHA}"; fi)
SHA7="${SHA::7}"
echo "sha=${SHA}" >> $GITHUB_OUTPUT
echo "sha7=${SHA7}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
ref: ${{ steps.sha.outputs.sha }}
fetch-depth: 0
- id: version
run: |
VERSION_MAJOR=$(grep -Eo "VERSION_MAJOR\s+[0-9]+" src/version.h | grep -Eo "[0-9]+")
VERSION_MINOR=$(grep -Eo "VERSION_MINOR\s+[0-9]+" src/version.h | grep -Eo "[0-9]+")
VERSION_REV=$(grep -Eo "VERSION_REV\s+[0-9]+" src/version.h | grep -Eo "[0-9]+")
VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}"
REVISION=$(git rev-list ${{ env.VERSION_START_SHA }}..${{ steps.sha.outputs.sha }} --count)
SHA="${GITHUB_SHA}"
echo "tag=${VERSION}-${REVISION}-${{ steps.sha.outputs.sha7 }}" >> $GITHUB_OUTPUT
prerelease:
runs-on: ubuntu-latest
needs: [ version ]
steps:
- id: download
run: |
WORKFLOWS=("pinmame" "pinmame32" "vpinmame" "libpinmame" "xpinmame")
curl -s "${{ env.ACTIONS_API_URL }}/runs" --output runs.json
for name in "${WORKFLOWS[@]}"
do
RUN_ID=$(jq -r --arg SHA "${{ needs.version.outputs.sha }}" --arg NAME "${name}" '.workflow_runs[] | select(.head_sha==$SHA and .name==$NAME) | .id' runs.json)
echo "Downloading ${name} artifact list ${RUN_ID}..."
curl -s "${{ env.ACTIONS_API_URL }}/runs/${RUN_ID}/artifacts" --output artifacts.json
ARTIFACTS=($(jq -r '.artifacts[] | .archive_download_url' artifacts.json))
for url in ${ARTIFACTS[@]}
do
echo "Downloading artifact: ${url}..."
curl -s -OJ -L -H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" ${url}
done
done
rm *.json
- id: create_release
uses: ncipollo/release-action@v1
with:
prerelease: true
name: "v${{ needs.version.outputs.tag }}"
tag: "v${{ needs.version.outputs.tag }}"
commit: ${{ needs.version.outputs.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "*"