ci: Correct versions file path in release workflow (#47) #5
Workflow file for this run
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
# 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)" |