Skip to content
This repository was archived by the owner on Apr 11, 2023. It is now read-only.

Commit 82de6d5

Browse files
committed
Implement release script and CI config
and add zeranoe ffmpeg 4.2.2 and rtmpdump 2.3
1 parent 67db83e commit 82de6d5

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed

.github/workflows/main.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Release
2+
3+
on:
4+
push: {}
5+
pull_request: {}
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- env:
13+
RELEASES_API_KEY: ${{ secrets.RELEASES_API_KEY }}
14+
run: ./release.sh

data.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[
2+
{
3+
"url": "https://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-4.2.2-win32-static.zip",
4+
"checksum": "1f6adff50db6cad54fdab15013c4c95cb6f83d7fe6d1167f3896cf4550573565",
5+
"filename": "ffmpeg-4.2.2-win32-static.zip",
6+
"sourcedir": "ffmpeg-4.2.2-win32-static",
7+
"targetdir": "ffmpeg",
8+
"files": [
9+
{
10+
"from": "bin/ffmpeg.exe",
11+
"to": "ffmpeg.exe"
12+
},
13+
{
14+
"from": "LICENSE.txt",
15+
"to": "LICENSE.txt"
16+
}
17+
]
18+
},
19+
{
20+
"url": "https://rtmpdump.mplayerhq.hu/download/rtmpdump-2.3-windows.zip",
21+
"checksum": "6948aa372f04952d5675917c6ca2c7c0bf6b109de21a4323adc93247fff0189f",
22+
"filename": "rtmpdump-2.3-windows.zip",
23+
"sourcedir": "rtmpdump-2.3",
24+
"targetdir": "rtmpdump",
25+
"files": [
26+
{
27+
"from": "rtmpdump.exe",
28+
"to": "rtmpdump.exe"
29+
},
30+
{
31+
"from": "COPYING",
32+
"to": "LICENSE.txt"
33+
}
34+
]
35+
}
36+
]

release.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
for var in GITHUB_ACTIONS GITHUB_REPOSITORY; do
5+
[[ -z "${!var}" ]] && { echo >&2 "Missing ${var} env var"; exit 1; }
6+
done
7+
8+
DATA="data.json"
9+
FILES=()
10+
11+
GITHUB_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}"
12+
GITHUB_API_HEADERS=(
13+
-H "Accept: application/vnd.github.v3+json"
14+
-H "User-Agent: ${GITHUB_REPOSITORY}"
15+
-H "Authorization: token ${RELEASES_API_KEY}"
16+
)
17+
18+
19+
ROOT="$(git rev-parse --show-toplevel)"
20+
TEMP=$(mktemp -d) && trap "rm -rf ${TEMP}" EXIT || exit 255
21+
cd "${TEMP}"
22+
23+
24+
while IFS=" " read -r url checksum filename; do
25+
echo "Downloading ${filename}"
26+
curl -s -L --output "${filename}" "${url}"
27+
echo "Comparing checksums"
28+
echo "${checksum} ${filename}" | sha256sum --check -
29+
FILES+=("${filename}")
30+
done < <(jq -r '.[] | "\(.url) \(.checksum) \(.filename)"' "${ROOT}/${DATA}")
31+
32+
33+
[[ "${GITHUB_REF}" =~ ^refs/tags/.+ ]] || { echo -e "Not a release, aborting\n\nDone"; exit 0; }
34+
[[ -z "${RELEASES_API_KEY}" ]] && { echo >&2 "Missing RELEASES_API_KEY env var"; exit 1; }
35+
36+
37+
TAG_NAME="${GITHUB_REF#refs/tags/}"
38+
39+
echo "Checking for existing release on tag: ${TAG_NAME}"
40+
RELEASE_ID=$(curl -s \
41+
-X GET \
42+
"${GITHUB_API_HEADERS[@]}" \
43+
"${GITHUB_API_URL}/releases/tags/${TAG_NAME}" \
44+
| jq -r ".id | select(. != null)"
45+
)
46+
47+
if [[ -n "${RELEASE_ID}" ]]; then
48+
echo "Release found: ${RELEASE_ID}"
49+
else
50+
RELEASE_ID=$(curl -s \
51+
-X POST \
52+
"${GITHUB_API_HEADERS[@]}" \
53+
-d "{\"tag_name\":\"${TAG_NAME}\",\"name\":\"${TAG_NAME}\"}" \
54+
"${GITHUB_API_URL}/releases" \
55+
| jq -r ".id | select(. != null)"
56+
)
57+
if [[ -z "${RELEASE_ID}" ]]; then
58+
echo >&2 "Could not create new release"
59+
exit 1
60+
fi
61+
echo "New release created: ${RELEASE_ID}"
62+
fi
63+
64+
for file in "${FILES[@]}"; do
65+
echo "Uploading release asset: ${file}"
66+
curl -s \
67+
-X POST \
68+
"${GITHUB_API_HEADERS[@]}" \
69+
-H "Content-Type: application/octet-stream" \
70+
-H "Content-Length: $(stat --printf="%s" "${file}")" \
71+
--data-binary "@${file}" \
72+
"https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets?name=${file}" \
73+
> /dev/null
74+
done
75+
76+
77+
echo -e "\nDone"

0 commit comments

Comments
 (0)