Skip to content

Commit 2e4025f

Browse files
committed
Add a new manual Draft Release workflow
Squashed commit of the following: commit 33d65067990f84bba9ff704ec6ae9b4446c091e3 Author: Paul Colby <[email protected]> Date: Mon Mar 10 12:40:49 2025 +1100 Restore buld jobs commit d107fba Author: Paul Colby <[email protected]> Date: Mon Mar 10 12:37:30 2025 +1100 Customise the release notes Specifically, pre-populate the recommended downloads section. commit 8b76197 Author: Paul Colby <[email protected]> Date: Mon Mar 10 11:35:04 2025 +1100 Shift the release job/s to thier own workflow commit 72967a9 Author: Paul Colby <[email protected]> Date: Mon Mar 10 09:44:52 2025 +1100 Add initial auto-release workflow steps
1 parent 211522e commit 2e4025f

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

.github/workflows/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
artifacts
2+
assets

.github/workflows/release.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env bash
2+
set -o errexit -o noclobber -o nounset -o pipefail
3+
4+
: "${ARTIFACTS_DIR:=$(realpath -m artifacts)}"
5+
: "${ASSETS_DIR:=$(realpath -m assets)}"
6+
readonly ARTIFACTS_DIR ASSETS_DIR TAG_NAME="${1:?Usage: ${BASH_SOURCE[0]} <tag-name>}"
7+
[[ ! -a "${ARTIFACTS_DIR}" && ! -a "${ASSETS_DIR}" ]] || {
8+
echo 'One or more output directories already exist.'
9+
printf 'Please delete the following directories to avoid errors:\n %s\n %s\n' "${ARTIFACTS_DIR}" "${ASSETS_DIR}"
10+
exit 2
11+
}
12+
printf 'Creating output directories:\n %s\n %s\n' "${ARTIFACTS_DIR}" "${ASSETS_DIR}"
13+
mkdir -p "${ARTIFACTS_DIR}" "${ASSETS_DIR}"
14+
15+
# Fetch the workflow runs for the tag.
16+
echo "Fetching workflow run info for: ${TAG_NAME}"
17+
runsList=$(gh run list --branch "${TAG_NAME}" --json 'name,number,databaseId,status,url,displayTitle')
18+
[[ -n "${runsList}" && "${runsList}" != '[]' ]] || {
19+
echo "Found no workflow runs for: ${TAG_NAME}"
20+
exit 3
21+
}
22+
title=$(jq --raw-output 'first.displayTitle' <<< "${runsList}")
23+
echo "Found workflow run info: ${title}"
24+
25+
# Check all workflows have completed.
26+
incomplete=$(jq --raw-output '.[]|select(.status != "completed")|[" ",.url,.name,.status]|join(" - ")' <<< "${runsList}")
27+
[[ -z "${incomplete}" ]] || {
28+
printf 'The following workflows are incomplete:\n%s\n' "${incomplete}"
29+
exit 4
30+
}
31+
32+
# Fetch the build artifacts.
33+
buildRunId=$(jq --raw-output '.[]|select(.name == "Build and Test").databaseId' <<< "${runsList}")
34+
docRunId=$(jq --raw-output '.[]|select(.name == "Documentation").databaseId' <<< "${runsList}")
35+
[[ -n "${buildRunId}" && -n "${docRunId}" ]] || {
36+
echo "Failed to find run IDs for build (${buildRunId}) and/or doc (${docRunId}) workflow runs."
37+
exit 5
38+
}
39+
40+
echo "Fetching artifacts for build run: ${buildRunId}"
41+
gh run download "${buildRunId}" --dir "${ARTIFACTS_DIR}"
42+
43+
echo "Fetching artifacts for docs run ${docRunId}"
44+
gh run download "${docRunId}" --dir "${ARTIFACTS_DIR}"
45+
46+
# Process the build artifacts into release assets.
47+
echo 'Compressing Linux and macOS binaries'
48+
find "${ARTIFACTS_DIR}" -maxdepth 1 -type d -name 'dokit-*' \
49+
-not -name '*-cov.*' -not -name '*.win.*' -not -name '*.AppImage' \
50+
-execdir tar -cJvf "${ASSETS_DIR}/{}.txz" --transform 's|^\./||' '{}' \;
51+
52+
echo 'Compressing Windows binaries'
53+
find "${ARTIFACTS_DIR}" -maxdepth 1 -type d -name 'dokit-*.win.*' -not -name '*-cov.*' \
54+
-execdir zip -9 -r "${ASSETS_DIR}/{}.zip" '{}' \;
55+
56+
echo 'Compressing test results'
57+
( cd "${ARTIFACTS_DIR}"; zip -9 -r "${ASSETS_DIR}/test-results.zip" 'coverage-report' 'test-results-'* )
58+
59+
echo 'Copying AppImages'
60+
find "${ARTIFACTS_DIR}" -type f -name '*.AppImage' -not -name '*-cov.*AppImage' -exec cp -av {} "${ASSETS_DIR}" \;
61+
62+
echo 'Compressing docs'
63+
find "${ARTIFACTS_DIR}" -maxdepth 1 -type d -name '*-docs' -execdir zip -9 -r "${ASSETS_DIR}/{}.zip" '{}' \;
64+
65+
# Create a new (draft) release.
66+
echo "Creating new draft release, with $(ls -1a "${ASSETS_DIR}" | wc -l) assets"
67+
lin=$(find "$ASSETS_DIR" -name '*.gcc.*.AppImage' -printf '%f\n' | sort -V | tail -n1)
68+
mac=$(find "$ASSETS_DIR" -name '*.macos-*.arm64-x86_64.clang.*' -printf '%f\n' | sort -V | tail -n1)
69+
win=$(find "$ASSETS_DIR" -name '*.win.x86-64.msvc.*.portable.zip' -printf '%f\n' | sort -V | tail -n1)
70+
readonly baseUrl="https://github.com/pcolby/dokit/releases/download/${TAG_NAME}" lin mac win
71+
gh release create "${TAG_NAME}" --draft --generate-notes --notes-file <(cat <<--
72+
_Add release notes here._
73+
74+
### Recommended Downloads
75+
76+
Feel free to download any of the assets below, but the recommended starting point would be:
77+
78+
* Linux: [${lin}](${baseUrl}/${lin})
79+
* macOS: [${mac}](${baseUrl}/${mac}) - tip: \`brew install qt6\`
80+
* Windows: [${win}](${baseUrl}/${win}) - tip: run the included \`vc_redist.x64.exe\` if you don't have the necessary Microsoft Visual C++ runtime installed already.
81+
-
82+
) --verify-tag "${ASSETS_DIR}/"*
83+
echo 'Done'

.github/workflows/release.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Draft Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: Tag to release
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
14+
env:
15+
GH_REPO: ${{ github.repository }}
16+
GH_TOKEN: ${{ github.token }}
17+
18+
jobs:
19+
release:
20+
runs-on: ubuntu-24.04
21+
steps:
22+
- name: Create draft release
23+
run: .github/workflows/release.sh "${TAG_NAME}"
24+
env:
25+
GH_REPO: ${{ github.repository }}
26+
GH_TOKEN: ${{ github.token }}
27+
TAG_NAME: ${{ github.event.inputs.tag }}

0 commit comments

Comments
 (0)