-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (154 loc) · 5.81 KB
/
Copy pathdraft.yml
File metadata and controls
173 lines (154 loc) · 5.81 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: "Draft"
on:
push:
branches:
- "master"
- "main"
tags: ["v[0-9]+.[0-9]+.[0-9]?"]
workflow_dispatch:
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
NIGHTLY_BODY: "${{ github.event.release.body }}"
LICENSE_FILE_REG: "LICENS*|LICENSE-*|LICENSE-MIT|LICENSE-APACHE"
LICENSE_FILES_WINDOWS: "LICENSE*"
GITHUB_BRANCH_TAG_NAME: "${{ github.ref_name }}"
CARGO_TERM_COLOR: "always"
CARGO_INCREMENTAL: "0"
RUST_BACKTRACE: "1"
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
PROJECT_NAME: "chapterize"
jobs:
build-unix:
name: "Draft - build-unix"
strategy:
matrix:
include:
- os: "ubuntu-latest"
target: "x86_64-unknown-linux-gnu"
runs-on: "${{ matrix.os }}"
steps:
- name: "Checkout sources"
uses: "actions/checkout@v7"
- name: "Setup Rust"
uses: "./.github/actions/setup-rust"
with:
target: "${{ matrix.target }}"
- name: "Pack release dir (with bundled ffmpeg)"
shell: "bash"
run: |
export ARTIFACT_NAME="${{ env.PROJECT_NAME }}-${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}"
export LICENSE_FILE="${{ env.LICENSE_FILE_REG }}"
cargo build --release --locked --target "${{ matrix.target }}"
mkdir -p "${ARTIFACT_NAME}"
cp "target/${{ matrix.target }}/release/${{ env.PROJECT_NAME }}" "${ARTIFACT_NAME}"
chmod +x build/fetch-ffmpeg.sh
./build/fetch-ffmpeg.sh "${{ matrix.target }}" "${ARTIFACT_NAME}"
find . -maxdepth 1 -type f -regex ".*\(${LICENSE_FILE}\)" -exec sh -c 'cp README.md "$@" "${ARTIFACT_NAME}"' _ {} +
cd "${ARTIFACT_NAME}"
zip -r "../${ARTIFACT_NAME}.zip" .
cd ..
- name: "Upload artifact"
uses: "actions/upload-artifact@v7"
with:
name: "${{ env.PROJECT_NAME }}-${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}"
path: "${{ env.PROJECT_NAME }}-${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}.zip"
if-no-files-found: "error"
compression-level: 9
build-windows:
name: "Draft - build-windows"
strategy:
matrix:
include:
- os: "windows-latest"
target: "x86_64-pc-windows-msvc"
runs-on: "${{ matrix.os }}"
steps:
- name: "Checkout sources"
uses: "actions/checkout@v7"
- name: "Setup Rust"
uses: "./.github/actions/setup-rust"
with:
target: "${{ matrix.target }}"
- name: "Build"
run: "cargo build --release --locked --target ${{ matrix.target }}"
- name: "Pack artifact"
shell: "powershell"
working-directory: "${{ github.workspace }}"
run: |
$ARTIFACT_NAME="${{ env.PROJECT_NAME }}-${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}"
$LICENSE_FILE="${{ env.LICENSE_FILES_WINDOWS }}"
New-Item -ItemType Directory -Path "$ARTIFACT_NAME"
Copy-Item -Path "target\\${{ matrix.target }}\\release\\${{ env.PROJECT_NAME }}.exe" -Destination "$ARTIFACT_NAME"
Copy-Item -Path "README.md", "$LICENSE_FILE" -Destination "$ARTIFACT_NAME"
Compress-Archive -Path "$ARTIFACT_NAME\\*" -Destination "$ARTIFACT_NAME.zip"
- name: "Upload artifact"
uses: "actions/upload-artifact@v7"
with:
name: "${{ env.PROJECT_NAME }}-${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}"
path: "${{ env.PROJECT_NAME }}-${{ matrix.target }}-${{ env.GITHUB_BRANCH_TAG_NAME }}.zip"
if-no-files-found: "error"
compression-level: 9
draft:
name: "Draft - draft"
if: ${{ startsWith(github.ref, 'refs/tags/') }}
permissions:
contents: write
runs-on: "ubuntu-latest"
needs: [build-unix, build-windows]
steps:
- name: "Checkout sources"
uses: "actions/checkout@v7"
- name: "Download artifacts"
uses: "actions/download-artifact@v8"
id: "artifact-download-step"
with:
merge-multiple: true
- name: "Draft"
uses: "softprops/action-gh-release@v3"
with:
fail_on_unmatched_files: true
draft: true
files: "${{ env.PROJECT_NAME }}-*"
generate_release_notes: true
nightly:
name: "Draft - nightly"
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
permissions:
contents: write
runs-on: "ubuntu-latest"
needs: [build-unix, build-windows]
steps:
- name: "Generate nightly body"
run: |
echo 'NIGHTLY_BODY<<EOF' >> $GITHUB_ENV
echo "From commit: ${GITHUB_SHA:0:8}" >> $GITHUB_ENV
echo "Generated on: $(date -u +\"%Y-%m-%d %H:%M\") UTC" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: "Checkout sources"
uses: "actions/checkout@v7"
- name: "Download artifacts"
uses: "actions/download-artifact@v8"
with:
merge-multiple: true
# Recreate floating nightly via API (no git push --force; no workflows scope).
# gh release delete --cleanup-tag drops release + tag; softprops recreates both.
- name: "Drop existing nightly release and tag"
env:
GH_TOKEN: "${{ github.token }}"
run: |
gh release delete nightly --yes --cleanup-tag 2>/dev/null || true
gh api --method DELETE "repos/${GITHUB_REPOSITORY}/git/refs/tags/nightly" 2>/dev/null || true
- name: "Release Nightly"
uses: "softprops/action-gh-release@v3"
with:
tag_name: "nightly"
prerelease: true
make_latest: false
fail_on_unmatched_files: true
files: "${{ env.PROJECT_NAME }}-*"
name: "Nightly Build"
body: "${{ env.NIGHTLY_BODY }}"
target_commitish: "${{ github.sha }}"