11name : " Draft"
2-
32on :
43 push :
54 branches :
65 - master
76 - main
8- tags : ["v[0-9]+.[0-9]+.[0-9]?? "]
7+ tags : ["v[0-9]+.[0-9]+.[0-9]?"]
98 workflow_dispatch :
109
1110concurrency :
1211 group : ${{ github.workflow }}-${{ github.ref }}
1312 cancel-in-progress : ${{ github.ref != 'refs/heads/main' }}
1413
1514env :
16- PROJECT_NAME : chapterize
1715 NIGHTLY_BODY : ${{ github.event.release.body }}
16+ LICENSE_FILE_REG : LICENS*|LICENSE-*|LICENSE-MIT|LICENSE-APACHE
17+ LICENSE_FILES_WINDOWS : LICENSE*
1818 GITHUB_BRANCH_TAG_NAME : ${{ github.ref_name }}
1919 CARGO_TERM_COLOR : always
2020 CARGO_INCREMENTAL : 0
2121 RUST_BACKTRACE : 1
2222 SCCACHE_GHA_ENABLED : true
2323 RUSTC_WRAPPER : sccache
24+ PROJECT_NAME : chapterize
2425
2526jobs :
26- build :
27- name : " Draft - ${{ matrix.target }} "
27+ build-unix :
28+ name : " Draft - build-unix "
2829 strategy :
29- fail-fast : false
3030 matrix :
3131 include :
32- # Linux
3332 - os : ubuntu-latest
3433 target : x86_64-unknown-linux-gnu
35- - os : ubuntu-24.04-arm
36- target : aarch64-unknown-linux-gnu
37- # Windows
38- - os : windows-latest
39- target : x86_64-pc-windows-msvc
40- - os : windows-11-arm
41- target : aarch64-pc-windows-msvc
42- # macOS
43- - os : macos-13
44- target : x86_64-apple-darwin
45- - os : macos-latest
46- target : aarch64-apple-darwin
4734 runs-on : ${{ matrix.os }}
4835 steps :
36+ - uses : actions/checkout@v7
37+
4938 - uses : ./.github/actions/setup-rust
5039 with :
5140 target : ${{ matrix.target }}
5241
53- - name : Build chapterize
54- shell : bash
55- run : cargo build --release --locked --target "${{ matrix.target }}"
56-
5742 - name : Pack release dir (with bundled ffmpeg)
5843 shell : bash
5944 run : |
60- set -euo pipefail
61- ARTIFACT_NAME="chapterize-${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}"
45+ export ARTIFACT_NAME="${{ env.PROJECT_NAME }}-${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}"
46+ export LICENSE_FILE="${{ env.LICENSE_FILE_REG }}"
47+ cargo build --release --locked --target "${{ matrix.target }}"
6248 mkdir -p "${ARTIFACT_NAME}"
49+ cp "target/${{ matrix.target }}/release/${{ env.PROJECT_NAME }}" "${ARTIFACT_NAME}"
50+ chmod +x build/fetch-ffmpeg.sh
51+ ./build/fetch-ffmpeg.sh "${{ matrix.target }}" "${ARTIFACT_NAME}"
52+ find . -maxdepth 1 -type f -regex ".*\(${LICENSE_FILE}\)" -exec sh -c 'cp README.md "$@" "${ARTIFACT_NAME}"' _ {} +
53+ cd "${ARTIFACT_NAME}"
54+ zip -r "../${ARTIFACT_NAME}.zip" .
55+ cd ..
56+
57+ - name : Upload artifact
58+ uses : actions/upload-artifact@v4
59+ with :
60+ name : ${{ env.PROJECT_NAME }}-${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}
61+ path : ${{ env.PROJECT_NAME }}-${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}.zip
62+ if-no-files-found : ' error'
63+ compression-level : ' 9'
6364
64- BIN_SRC="target/${{ matrix.target }}/release/chapterize"
65- if [[ "${{ matrix.target }}" == *windows* ]]; then
66- BIN_SRC="${BIN_SRC}.exe"
67- fi
68- cp -f "${BIN_SRC}" "${ARTIFACT_NAME}/"
65+ build-windows :
66+ name : " Draft - build-windows"
67+ strategy :
68+ matrix :
69+ include :
70+ - os : windows-latest
71+ target : x86_64-pc-windows-msvc
72+ runs-on : ${{ matrix.os }}
73+ steps :
74+ - uses : actions/checkout@v7
6975
70- cp -f README.md LICENSE "${ARTIFACT_NAME}/" 2>/dev/null || cp -f README.md "${ARTIFACT_NAME}/"
71- [[ -f LICENSE ]] && cp -f LICENSE "${ARTIFACT_NAME}/"
76+ - uses : ./.github/actions/setup-rust
77+ with :
78+ target : ${{ matrix.target }}
7279
73- chmod +x build/fetch-ffmpeg.sh
74- ./ build/fetch-ffmpeg.sh " ${{ matrix.target }}" "${ARTIFACT_NAME}"
80+ - name : Build
81+ run : cargo build --release --locked --target ${{ matrix.target }}
7582
76- # Zip from inside the folder so paths are clean
77- if command -v zip >/dev/null 2>&1; then
78- (cd "${ARTIFACT_NAME}" && zip -r "../${ARTIFACT_NAME}.zip" .)
79- else
80- # Windows runners without zip: use PowerShell compress
81- powershell.exe -NoProfile -Command \
82- "Compress-Archive -Path '${ARTIFACT_NAME}\*' -DestinationPath '${ ARTIFACT_NAME}.zip' -Force "
83- fi
84- ls -lah "${ ARTIFACT_NAME}.zip "
85- ls -lah "${ ARTIFACT_NAME} "
83+ - name : Pack artifact
84+ shell : powershell
85+ working-directory : ${{ github.workspace }}
86+ run : |
87+ $ARTIFACT_NAME="${{ env.PROJECT_NAME }}-${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}"
88+ $LICENSE_FILE="${{ env.LICENSE_FILES_WINDOWS }}"
89+ New-Item -ItemType Directory -Path "$ ARTIFACT_NAME"
90+ Copy-Item -Path "target\\${{ matrix.target }}\\release\\${{ env.PROJECT_NAME }}.exe" -Destination "$ARTIFACT_NAME"
91+ Copy-Item -Path "README.md", "$LICENSE_FILE" -Destination "$ ARTIFACT_NAME"
92+ Compress-Archive -Path "$ARTIFACT_NAME\*" -Destination "$ARTIFACT_NAME.zip "
8693
8794 - name : Upload artifact
8895 uses : actions/upload-artifact@v4
8996 with :
90- name : chapterize -${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}
91- path : chapterize -${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}.zip
92- if-no-files-found : error
93- compression-level : " 9 "
97+ name : ${{ env.PROJECT_NAME }} -${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}
98+ path : ${{ env.PROJECT_NAME }} -${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}.zip
99+ if-no-files-found : ' error'
100+ compression-level : ' 9 '
94101
95102 draft :
96103 name : " Draft - draft"
97104 if : ${{ startsWith(github.ref, 'refs/tags/') }}
98105 permissions :
99106 contents : write
100107 runs-on : ubuntu-latest
101- needs : [build]
108+ needs : [build-unix, build-windows ]
102109 steps :
103110 - name : Checkout sources
104111 uses : actions/checkout@v7
105112
106113 - name : Download artifacts
107114 uses : actions/download-artifact@v4
115+ id : artifact-download-step
108116 with :
109117 merge-multiple : true
110118
111- - name : Draft release
119+ - name : Draft
112120 uses : softprops/action-gh-release@v2
113121 with :
114122 fail_on_unmatched_files : true
115123 draft : true
116124 files : |
117- chapterize -*
125+ ${{ env.PROJECT_NAME }} -*
118126 generate_release_notes : true
119- body : |
120- ## Bundled tools
121- Each zip contains:
122- - `chapterize` (or `chapterize.exe`)
123- - `ffmpeg` / `ffprobe` matched to the target arch
124- - `README.md`, `LICENSE`, `FFMPEG_NOTICE.txt`
125- - `third_party/ffmpeg/` upstream attribution
126-
127- FFmpeg is a **separate** program (LGPL static builds on Linux/Windows via BtbN; macOS via eugeneware/ffmpeg-static). Delete the bundled binaries anytime and use system installs on `PATH` instead.
128127
129128 nightly :
130129 name : " Draft - nightly"
131130 if : ${{ !startsWith(github.ref, 'refs/tags/') }}
132131 permissions :
133132 contents : write
134133 runs-on : ubuntu-latest
135- needs : [build]
134+ needs : [build-unix, build-windows ]
136135 steps :
137136 - name : Generate nightly body
138137 run : |
139- echo 'NIGHTLY_BODY<<EOF' >> "$GITHUB_ENV"
140- echo "From commit: ${GITHUB_SHA:0:8}" >> "$GITHUB_ENV"
141- echo "Generated on: $(date -u +"%Y-%m-%d %H:%M") UTC" >> "$GITHUB_ENV"
142- echo "" >> "$GITHUB_ENV"
143- echo "Zips include chapterize + arch-matched ffmpeg/ffprobe." >> "$GITHUB_ENV"
144- echo "EOF" >> "$GITHUB_ENV"
138+ echo 'NIGHTLY_BODY<<EOF' >> $GITHUB_ENV
139+ echo "From commit: ${GITHUB_SHA:0:8}" >> $GITHUB_ENV
140+ echo "Generated on: $(date -u +\"%Y-%m-%d %H:%M\") UTC" >> $GITHUB_ENV
141+ echo "EOF" >> $GITHUB_ENV
145142
146143 - name : Checkout sources
147144 uses : actions/checkout@v7
@@ -164,7 +161,7 @@ jobs:
164161 prerelease : true
165162 fail_on_unmatched_files : true
166163 files : |
167- chapterize -*
164+ ${{ env.PROJECT_NAME }} -*
168165 name : Nightly Build
169166 body : ${{ env.NIGHTLY_BODY }}
170167 target_commitish : ${{ github.sha }}
0 commit comments