Skip to content

prerelease

prerelease #18

Workflow file for this run

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@v3
with:
ref: ${{ steps.sha.outputs.sha }}
fetch-depth: 0
- id: version
run: |
VERSION=$(grep -Eo "[0-9\.]+" src/version.c | head -1)
REVISION=$(git rev-list ${{ env.VERSION_START_SHA }}..${{ steps.sha.outputs.sha }} --count)
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: "*"