TypePHP 编译器 https://swoole.com/aot/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

129 lines
4.4 KiB

name: Package release
on:
push:
tags:
- "v*"
permissions:
actions: read
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
name: Publish ${{ github.ref_name }}
runs-on: ubuntu-22.04
timeout-minutes: 240
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Wait for tested binary packages
shell: bash
run: |
set -euo pipefail
wait_for_workflow() {
local workflow="$1"
local output_name="$2"
local run_json run_id status conclusion
for attempt in $(seq 1 960); do
run_json="$(gh run list \
--repo "${GITHUB_REPOSITORY}" \
--workflow "${workflow}" \
--commit "${GITHUB_SHA}" \
--event push \
--limit 20 \
--json databaseId,status,conclusion,headBranch,createdAt)"
run_id="$(jq -r --arg tag "${GITHUB_REF_NAME}" '
[.[] | select(.headBranch == $tag)]
| sort_by(.createdAt)
| last
| .databaseId // empty
' <<<"${run_json}")"
if [[ -z "${run_id}" ]]; then
echo "Waiting for ${workflow} to start for tag ${GITHUB_REF_NAME}..."
sleep 15
continue
fi
status="$(jq -r --argjson id "${run_id}" '
.[] | select(.databaseId == $id) | .status
' <<<"${run_json}")"
conclusion="$(jq -r --argjson id "${run_id}" '
.[] | select(.databaseId == $id) | .conclusion
' <<<"${run_json}")"
if [[ "${status}" == "completed" ]]; then
if [[ "${conclusion}" != "success" ]]; then
echo "${workflow} run ${run_id} completed with ${conclusion}" >&2
exit 1
fi
echo "${workflow} run ${run_id} succeeded"
echo "${output_name}=${run_id}" >> "${GITHUB_ENV}"
return 0
fi
echo "Waiting for ${workflow} run ${run_id}: ${status}"
sleep 15
done
echo "Timed out waiting for ${workflow}" >&2
exit 1
}
wait_for_workflow tests.yml TESTS_RUN_ID
wait_for_workflow windows-build.yml WINDOWS_RUN_ID
- name: Download tested packages
shell: bash
run: |
set -euo pipefail
mkdir -p dist/linux dist/windows
gh run download "${TESTS_RUN_ID}" \
--repo "${GITHUB_REPOSITORY}" \
--pattern 'release-linux-*' \
--dir dist/linux
gh run download "${WINDOWS_RUN_ID}" \
--repo "${GITHUB_REPOSITORY}" \
--pattern 'release-windows-*' \
--dir dist/windows
test "$(find dist/linux -type f -name '*.tar.gz' | wc -l)" -eq 1
test "$(find dist/windows -type f -name '*.zip' | wc -l)" -eq 1
- name: Prepare release assets
shell: bash
run: |
set -euo pipefail
mkdir -p release-assets
find dist -type f \( -name '*.tar.gz' -o -name '*.zip' \) \
-exec cp '{}' release-assets/ \;
test "$(find release-assets -maxdepth 1 -type f \( -name '*.tar.gz' -o -name '*.zip' \) | wc -l)" -eq 2
(
cd release-assets
sha256sum ./*.tar.gz ./*.zip > SHA256SUMS
)
ls -lh release-assets
- name: Publish GitHub release
shell: bash
run: |
set -euo pipefail
mapfile -t assets < <(find release-assets -maxdepth 1 -type f | sort)
if gh release view "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
gh release upload "${GITHUB_REF_NAME}" "${assets[@]}" \
--repo "${GITHUB_REPOSITORY}" \
--clobber
else
gh release create "${GITHUB_REF_NAME}" "${assets[@]}" \
--repo "${GITHUB_REPOSITORY}" \
--verify-tag \
--title "TypePHP ${GITHUB_REF_NAME}" \
--generate-notes
fi