prerelease #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "*" |