Skip to content

Commit 1c348f5

Browse files
Merge pull request #708 from YDX-2147483647/ci
ci: Correct file paths and allow testing `release.yml`
2 parents 8e2d20b + 4ee58de commit 1c348f5

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
release:
55
types:
66
- published
7+
workflow_dispatch:
8+
# Allow testing the release process without publishing a real release.
79

810
jobs:
911
build:
@@ -12,6 +14,10 @@ jobs:
1214

1315
steps:
1416
- uses: actions/checkout@v6
17+
with:
18+
# Fetch more history for workflow_dispatch, required by `just update-version`.
19+
fetch-depth: ${{ github.event_name == 'workflow_dispatch' && 100 || 1 }}
20+
fetch-tags: ${{ github.event_name == 'workflow_dispatch' }}
1521
- uses: TeX-Live/setup-texlive-action@v3
1622
with:
1723
version: 2025
@@ -41,17 +47,17 @@ jobs:
4147
fc-cache
4248
4349
- name: Update version if prerelease
44-
if: ${{ github.event.release.prerelease }}
50+
if: ${{ github.event_name == 'workflow_dispatch' || github.event.release.prerelease }}
4551
# 目前发布正式版时,会手动提升版本号
46-
run: python scripts/update_version.py
52+
run: just update-version
4753

4854
- run: just doc handbooks
4955

5056
- name: Upload bithesis.pdf for later usage.
5157
uses: actions/upload-artifact@v6
5258
with:
5359
name: bithesis
54-
path: bithesis.pdf
60+
path: src/bithesis.pdf
5561
- name: Upload handbooks for later usage.
5662
uses: actions/upload-artifact@v6
5763
with:
@@ -61,7 +67,7 @@ jobs:
6167
uses: actions/upload-artifact@v6
6268
with:
6369
name: cls
64-
path: "*.cls"
70+
path: "src/*.cls"
6571

6672
publish_templates:
6773
name: Publish ${{ matrix.template }}
@@ -105,28 +111,31 @@ jobs:
105111
uses: actions/download-artifact@v7
106112
with:
107113
name: bithesis
114+
path: src
108115
- name: Download `*.cls`
109116
uses: actions/download-artifact@v7
110117
with:
111118
name: cls
119+
path: src
112120
- name: Copy manual to the template folder.
113121
run: |
114-
mv bithesis.pdf ./templates/${{ matrix.template }}
122+
mv src/bithesis.pdf ./templates/${{ matrix.template }}
115123
just copy-only
116124
- name: Install zip
117125
uses: montudor/action-zip@v1
118126
- name: Zip files under ./${{ matrix.template }}
119127
run: zip -qq -r ./${{ matrix.template }}.zip ./${{ matrix.template }}
120128
working-directory: ./templates
121129
- name: Upload ${{ matrix.template }}.zip to release
130+
if: ${{ github.event_name == 'release' }}
122131
run: |
123132
gh release upload ${{ github.event.release.tag_name }} \
124133
"./templates/${{ matrix.template }}.zip#模板包·${{ matrix.label }} — ${{ matrix.template }}.zip"
125134
env:
126135
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127136

128137
publish_cls:
129-
name: Publish ${{ matrix.cls }}
138+
name: Publish ${{ matrix.cls.name }}.cls
130139
runs-on: ubuntu-latest
131140
needs: build
132141

@@ -146,17 +155,19 @@ jobs:
146155
uses: actions/download-artifact@v7
147156
with:
148157
name: cls
158+
path: src
149159
- name: Upload ${{ matrix.cls.name }}.cls to release
160+
if: ${{ github.event_name == 'release' }}
150161
run: |
151162
gh release upload ${{ github.event.release.tag_name }} \
152-
"${{ matrix.cls.name }}.cls#文档类·${{ matrix.cls.label }} — ${{ matrix.cls.name }}.cls(用于升级替换)"
163+
"src/${{ matrix.cls.name }}.cls#文档类·${{ matrix.cls.label }} — ${{ matrix.cls.name }}.cls(用于升级替换)"
153164
env:
154165
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155166

156167
release_notes:
157168
name: Populate release notes with latest changelog and PDFs
158169
runs-on: ubuntu-latest
159-
# Makesure it's the last job.
170+
# Make sure it's the last job.
160171
needs: [build, publish_cls, publish_templates]
161172
outputs:
162173
release_body: ${{ steps.git-cliff.outputs.content }}
@@ -182,10 +193,12 @@ jobs:
182193
uses: actions/download-artifact@v7
183194
with:
184195
name: bithesis
196+
path: src
185197
- name: Upload bithesis.pdf and changelog
186198
uses: svenstaro/upload-release-action@v2
199+
if: ${{ github.event_name == 'release' }}
187200
with:
188-
file: bithesis.pdf
201+
file: src/bithesis.pdf
189202
repo_token: ${{ secrets.GITHUB_TOKEN }}
190203
tag: ${{ github.ref }}
191204
overwrite: true
@@ -205,6 +218,7 @@ jobs:
205218
name: handbooks
206219
path: handbook
207220
- name: Upload handbooks
221+
if: ${{ github.event_name == 'release' }}
208222
run: |
209223
gh release upload ${{ github.event.release.tag_name }} \
210224
"handbook/undergraduate-handbook.pdf#快速使用指南·本科"
@@ -226,6 +240,7 @@ jobs:
226240
uses: actions/download-artifact@v7
227241
with:
228242
name: bithesis
243+
path: src
229244
- name: Download handbooks
230245
uses: actions/download-artifact@v7
231246
with:
@@ -235,7 +250,7 @@ jobs:
235250
- uses: actions/upload-artifact@v6
236251
with:
237252
name: ctan-pkg
238-
path: bithesis.zip
253+
path: target/bithesis.zip
239254
- name: Determine version
240255
id: version
241256
run: |
@@ -244,10 +259,10 @@ jobs:
244259
echo "date=$(date '+%Y-%m-%d')" >> "$GITHUB_OUTPUT"
245260
- name: Upload to CTAN
246261
uses: paolobrasolin/ctan-submit-action@v1
247-
if: ${{ ! github.event.release.prerelease }}
262+
if: ${{ github.event_name == 'release' && ! github.event.release.prerelease }}
248263
with:
249264
action: upload
250-
file_path: bithesis.zip
265+
file_path: target/bithesis.zip
251266
fields: |
252267
update: "true"
253268
pkg: bithesis
@@ -256,7 +271,7 @@ jobs:
256271
email: bithesis@bitnp.net
257272
uploader: Feng Kaiyu
258273
- name: Report
259-
if: ${{ ! github.event.release.prerelease }}
274+
if: ${{ github.event_name == 'release' && ! github.event.release.prerelease }}
260275
run: >
261276
echo "🎉 Successfully upload
262277
${{ steps.version.outputs.number }} (${{ steps.version.outputs.date }})
@@ -265,7 +280,7 @@ jobs:
265280
changelog:
266281
name: Update CHANGELOG
267282
runs-on: ubuntu-latest
268-
if: ${{ ! github.event.release.prerelease }}
283+
if: ${{ github.event_name == 'release' && ! github.event.release.prerelease }}
269284
steps:
270285
- name: Checkout
271286
uses: actions/checkout@v6

justfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ regression-test *ARGS: copy
9797
target-dir:
9898
@mkdir -p target
9999

100+
# Update the version number for prereleases (mainly for CI)
101+
[group('release')]
102+
update-version SUFFIX="":
103+
python scripts/update_version.py {{ SUFFIX }}
104+
100105
# Build the ZIP for submission to CTAN (mainly for CI)
101106
[group('release')]
102107
pkg: doc handbooks pkg-only

scripts/update_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def get_date() -> datetime:
7070

7171
def update(human_version: str | None = None) -> None:
7272
"""Update versions in `bithesis.dtx` with an optional `human_version` suffix."""
73-
file = Path(__file__).parent.parent / "bithesis.dtx"
73+
file = Path(__file__).parent.parent / "src/bithesis.dtx"
7474
doc = file.read_text(encoding="utf-8")
7575

7676
version = get_version()

0 commit comments

Comments
 (0)