-
Notifications
You must be signed in to change notification settings - Fork 9
130 lines (111 loc) · 4.44 KB
/
release.yaml
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# A workflow to build and release fresh binaries.
name: Release
# Runs when a new tag is created. Creates a release for that tag, then builds
# ffmpeg and ffprobe on all OS & CPU combinations, then attaches them to the
# release.
on:
push:
tags:
- "*"
# NOTE: Set the repository variable ENABLE_DEBUG to enable debugging via tmate on
# failure.
# NOTE: Set the repository variable ENABLE_SELF_HOSTED to enable self-hosted
# runners such as linux-arm64. This is set on the official repo, but forks
# will have to opt in after setting up their own self-hosted runners.
jobs:
# On a single Linux host, draft a release. Later, different hosts will build
# for each OS/CPU in parallel, and then attach the resulting binaries to this
# draft.
draft_release:
name: Draft release
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.draft_release.outputs.release_id }}
steps:
- uses: actions/checkout@v4
with:
path: repo-src
- name: Draft release
id: draft_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
set -x
# Create a draft release associated with the tag that triggered this
# workflow.
tag="${{ github.ref }}"
(cd repo-src/api-client && npm ci)
release_id=$(node ./repo-src/api-client/main.js draft-release "$tag")
echo "::set-output name=release_id::$release_id"
build:
needs: draft_release
uses: ./.github/workflows/build.yaml
with:
release_id: ${{ needs.draft_release.outputs.release_id }}
secrets:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish_release:
name: Publish release
needs: [draft_release, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: repo-src
- name: Publish release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
set -x
# Compile the release notes (the "body" of the release) with the date
# and the versions of the software we built.
# The format provided by "date -I" is "YYYY-MM-DD".
echo "Date:" >> body.txt
echo " - $(date -I)" >> body.txt
echo "" >> body.txt
echo "$GITHUB_REPOSITORY version:" >> body.txt
echo " - $repo_tag" >> body.txt
echo "" >> body.txt
echo "Software versions:" >> body.txt
cat repo-src/versions.txt | \
sed -e 's/^/ - /' >> body.txt
echo "" >> body.txt
# Update the release notes with this preliminary version. This is
# what gets emailed out when we publish the release below.
release_id="${{ needs.draft_release.outputs.release_id }}"
(cd repo-src/api-client && npm ci)
node ./repo-src/api-client/main.js \
update-release-body "$release_id" "$(cat body.txt)"
# Now we have to take the release out of draft mode. Until we do, we
# can't get download URLs for the assets.
node ./repo-src/api-client/main.js \
publish-release "$release_id"
# The downloads are sometimes a bit flaky (responding with 404) if we
# don't put some delay between publication and download. This number
# is arbitrary, but experimentally, it seems to solve the issue.
sleep 30
# Next, download the assets.
node ./repo-src/api-client/main.js \
download-all-assets "$release_id" assets/
# Now add the MD5 sums to the release notes.
echo "MD5 sums:" >> body.txt
(cd assets; md5sum * | sed -e 's/^/ - /') >> body.txt
# Now update the release notes one last time, with the MD5 sums
# appended.
node ./repo-src/api-client/main.js \
update-release-body "$release_id" "$(cat body.txt)"