Skip to content

Commit e69e607

Browse files
authored
Добавлена публикация docx файлов в релиз (#10)
* add .docx building * add .docx to release * extract common variables and targets to Common.mk * fixed appending to array in build_course.sh
1 parent c641901 commit e69e607

File tree

10 files changed

+68
-51
lines changed

10 files changed

+68
-51
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v3
1717
- name: Build all courses
18-
run: ./scripts/build_all.sh -o '${{ env.BUILD_DIRECTORY }}'
18+
run: |
19+
apk add --no-cache pandoc
20+
/bin/sh -x ./scripts/build_all.sh -o '${{ env.BUILD_DIRECTORY }}'
1921
- uses: actions/upload-artifact@v3
2022
with:
2123
name: ${{ env.RESULT_NAME }}
2224
path: ${{ env.BUILD_DIRECTORY }}
23-
if-no-files-found: error
25+
if-no-files-found: error

.github/workflows/release_on_tag.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,16 @@ jobs:
1616
BUILD_DIRECTORY: 'build'
1717
steps:
1818
- uses: actions/checkout@v3
19-
- name: Pull Container
20-
run: |
21-
docker pull asciidoctor/docker-asciidoctor:latest
2219
- name: Build all courses
2320
run: |
2421
docker run \
2522
--rm -v '${{ github.workspace }}':/documents \
26-
asciidoctor/docker-asciidoctor \
27-
./scripts/build_all.sh -o '${{ env.BUILD_DIRECTORY }}' -s '${{ github.ref_name}}'
23+
asciidoctor/docker-asciidoctor:latest \
24+
/bin/sh -cx "apk add --no-cache pandoc; \
25+
./scripts/build_all.sh -o '${{ env.BUILD_DIRECTORY }}' -s '${{ github.ref_name}}'"
2826
- name: Release all courses assets
2927
run: |
30-
./scripts/release_all.sh '${{ github.ref_name}}' \
28+
bash -x ./scripts/release_all.sh '${{ github.ref_name}}' \
3129
-o '${{ env.BUILD_DIRECTORY }}' \
3230
-s '${{ github.ref_name}}' \
3331
'${{ env.RELEASE_TITLE }}'

Common.mk

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
ASCIIDOCTOR_PDF = asciidoctor-pdf
2+
ASCIIDOCTOR = asciidoctor
3+
PANDOC = pandoc
4+
5+
ROOT_ASCIIDOC_NAME = Course
6+
7+
CHAPTERS_DIR = Chapters
8+
CHAPTERS = $(wildcard $(CHAPTERS_DIR)/*.adoc)
9+
10+
ROOT_ASCIIDOC = $(ROOT_ASCIIDOC_NAME).adoc
11+
RESULT_PDF = $(ROOT_ASCIIDOC_NAME).pdf
12+
RESULT_XML = $(ROOT_ASCIIDOC_NAME).xml
13+
RESULT_DOCX = $(ROOT_ASCIIDOC_NAME).docx
14+
15+
THEME = theme.yml
16+
REFERENCE = custom-reference.docx
17+
STYLE = tango
18+
19+
.PHONY: all
20+
all: $(RESULT_PDF) $(RESULT_DOCX)
21+
22+
.PHONY: asciidoctor
23+
asciidoctor: $(RESULT_PDF) $(RESULT_XML)
24+
25+
.PHONY: pandoc
26+
pandoc: $(RESULT_DOCX)
27+
28+
.PHONY: clean
29+
clean:
30+
$(RM) $(RESULT_PDF) $(RESULT_XML) $(RESULT_DOCX)
31+
32+
$(RESULT_XML): $(ROOT_ASCIIDOC) $(CHAPTERS)
33+
$(ASCIIDOCTOR) \
34+
--backend docbook \
35+
--out-file='$@' '$<'
36+
37+
$(RESULT_DOCX): $(RESULT_XML) $(REFERENCE)
38+
$(PANDOC) \
39+
--from docbook \
40+
--reference-doc=$(REFERENCE) \
41+
--highlight-style $(STYLE) \
42+
--output '$@' '$<'

LFD112x-RU/Makefile

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
1-
ASCIIDOCTOR_PDF = asciidoctor-pdf
2-
3-
ROOT_ASCIIDOC_NAME = Course
4-
5-
CHAPTERS_DIR = Chapters
6-
CHAPTERS = $(wildcard $(CHAPTERS_DIR)/*.adoc)
7-
8-
ROOT_ASCIIDOC = $(ROOT_ASCIIDOC_NAME).adoc
9-
RESULT_PDF = $(ROOT_ASCIIDOC_NAME).pdf
10-
11-
THEME = theme.yml
12-
13-
.PHONY: all
14-
all: $(RESULT_PDF)
1+
include ../Common.mk
152

163
$(RESULT_PDF): $(ROOT_ASCIIDOC) $(CHAPTERS) $(THEME)
174
$(ASCIIDOCTOR_PDF) \
185
-r asciidoctor-mathematical \
196
-a mathematical-format=svg \
207
--theme $(THEME) \
218
--out-file='$@' '$<'
22-
23-
.PHONY: clean
24-
clean:
25-
$(RM) $(RESULT_PDF)

LFD112x-RU/custom-reference.docx

9.96 KB
Binary file not shown.

LFD113x-RU/Makefile

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
1-
ASCIIDOCTOR_PDF = asciidoctor-pdf
2-
3-
ROOT_ASCIIDOC_NAME = Course
4-
5-
CHAPTERS_DIR = Chapters
6-
CHAPTERS = $(wildcard $(CHAPTERS_DIR)/*.adoc)
7-
8-
ROOT_ASCIIDOC = $(ROOT_ASCIIDOC_NAME).adoc
9-
RESULT_PDF = $(ROOT_ASCIIDOC_NAME).pdf
10-
11-
THEME = theme.yml
12-
13-
.PHONY: all
14-
all: $(RESULT_PDF)
1+
include ../Common.mk
152

163
$(RESULT_PDF): $(ROOT_ASCIIDOC) $(CHAPTERS) $(THEME)
174
$(ASCIIDOCTOR_PDF) \
185
--theme $(THEME) \
196
--out-file='$@' '$<'
20-
21-
.PHONY: clean
22-
clean:
23-
$(RM) $(RESULT_PDF)

LFD113x-RU/custom-reference.docx

9.96 KB
Binary file not shown.

scripts/build_all.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Usage: $0 [OPTION]...
1212
Build artifacts of the all courses
1313
-h, --help print this help message and exit
1414
-o, --out-dir DIRECTORY name of the DIRECTORY for all built artifacts
15-
-s, --suffix SUFFIX SUFFIX for output pdf filename
15+
-s, --suffix SUFFIX SUFFIX for output filename
1616
1717
Examples:
1818
$0
@@ -79,7 +79,8 @@ fi
7979
while IFS="" read -r line || [ -n "$line" ]
8080
do
8181
COURSE_NAME=$(get_info "$line" 1)
82-
OUT_FILENAME="$(get_info "$line" 2)$SUFFIX.pdf"
82+
OUT_FILENAME="$(get_info "$line" 2)$SUFFIX"
8383

8484
"$BASEDIR/build_course.sh" -o "$BUILDDIR/$OUT_FILENAME" "$COURSE_NAME"
85+
8586
done < "$COURSES"

scripts/build_course.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ function usage() {
88
Usage: $0 [OPTION] COURSE_NAME
99
1010
Build artifacts of the course with COURSE_NAME
11-
-o, --out FILENAME output pdf FILENAME
11+
-o, --out FILENAME output FILENAME without extension
1212
-h, --help print this help message and exit
1313
1414
Examples:
1515
$0 LFD113x-RU
16-
$0 -o 'Инструментарий_и_компиляторные_оптимизации_для_RISC-V_(LFD113x)_RU.pdf' LFD113x-RU
16+
$0 -o 'Инструментарий_и_компиляторные_оптимизации_для_RISC-V_(LFD113x)_RU' LFD113x-RU
1717
tac
1818
}
1919

2020

2121
# Parse arguments
2222
COURSEDIR=""
23+
FILENAME=""
2324
MAKEOPTS=()
2425

2526
while [ "$1" != "" ]; do
@@ -29,7 +30,7 @@ while [ "$1" != "" ]; do
2930
exit 0
3031
;;
3132
-o|--out)
32-
MAKEOPTS+=("RESULT_PDF=$2")
33+
FILENAME=$2
3334
shift 2
3435
;;
3536
-*)
@@ -56,5 +57,11 @@ if [ "$COURSEDIR" == "" ]; then
5657
exit 1
5758
fi
5859

60+
if [ "$FILENAME" != "" ]; then
61+
MAKEOPTS+=("RESULT_DOCX=${FILENAME}.docx")
62+
MAKEOPTS+=("RESULT_PDF=${FILENAME}.pdf")
63+
MAKEOPTS+=("RESULT_XML=${FILENAME}.xml")
64+
fi
65+
5966
# Build selected course
6067
make -C "$COURSEDIR" "${MAKEOPTS[@]}"

scripts/release_all.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ fi
9292
# Release all files in build directory
9393
while IFS="" read -r line || [ -n "$line" ]
9494
do
95-
OUT_FILENAME="$(get_info "$line" 2)$SUFFIX.pdf"
95+
OUT_FILENAME="$(get_info "$line" 2)$SUFFIX"
9696
LABEL=$(get_info "$line" 3)
9797

98-
"$BASEDIR/release_file.sh" "$TAG" -t "$TITLE" "$BUILDDIR/$OUT_FILENAME" "$LABEL"
98+
"$BASEDIR/release_file.sh" "$TAG" -t "$TITLE" "$BUILDDIR/${OUT_FILENAME}.pdf" "${LABEL} (pdf)"
99+
"$BASEDIR/release_file.sh" "$TAG" -t "$TITLE" "$BUILDDIR/${OUT_FILENAME}.docx" "${LABEL} (docx)"
99100
done < "$COURSES"

0 commit comments

Comments
 (0)