Skip to content

Commit

Permalink
Добавлена публикация docx файлов в релиз (#10)
Browse files Browse the repository at this point in the history
* add .docx building
* add .docx to release
* extract common variables and targets to Common.mk
* fixed appending to array in build_course.sh
  • Loading branch information
AfoninaOlga authored Jul 17, 2023
1 parent c641901 commit e69e607
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 51 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build all courses
run: ./scripts/build_all.sh -o '${{ env.BUILD_DIRECTORY }}'
run: |
apk add --no-cache pandoc
/bin/sh -x ./scripts/build_all.sh -o '${{ env.BUILD_DIRECTORY }}'
- uses: actions/upload-artifact@v3
with:
name: ${{ env.RESULT_NAME }}
path: ${{ env.BUILD_DIRECTORY }}
if-no-files-found: error
if-no-files-found: error
10 changes: 4 additions & 6 deletions .github/workflows/release_on_tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@ jobs:
BUILD_DIRECTORY: 'build'
steps:
- uses: actions/checkout@v3
- name: Pull Container
run: |
docker pull asciidoctor/docker-asciidoctor:latest
- name: Build all courses
run: |
docker run \
--rm -v '${{ github.workspace }}':/documents \
asciidoctor/docker-asciidoctor \
./scripts/build_all.sh -o '${{ env.BUILD_DIRECTORY }}' -s '${{ github.ref_name}}'
asciidoctor/docker-asciidoctor:latest \
/bin/sh -cx "apk add --no-cache pandoc; \
./scripts/build_all.sh -o '${{ env.BUILD_DIRECTORY }}' -s '${{ github.ref_name}}'"
- name: Release all courses assets
run: |
./scripts/release_all.sh '${{ github.ref_name}}' \
bash -x ./scripts/release_all.sh '${{ github.ref_name}}' \
-o '${{ env.BUILD_DIRECTORY }}' \
-s '${{ github.ref_name}}' \
'${{ env.RELEASE_TITLE }}'
Expand Down
42 changes: 42 additions & 0 deletions Common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ASCIIDOCTOR_PDF = asciidoctor-pdf
ASCIIDOCTOR = asciidoctor
PANDOC = pandoc

ROOT_ASCIIDOC_NAME = Course

CHAPTERS_DIR = Chapters
CHAPTERS = $(wildcard $(CHAPTERS_DIR)/*.adoc)

ROOT_ASCIIDOC = $(ROOT_ASCIIDOC_NAME).adoc
RESULT_PDF = $(ROOT_ASCIIDOC_NAME).pdf
RESULT_XML = $(ROOT_ASCIIDOC_NAME).xml
RESULT_DOCX = $(ROOT_ASCIIDOC_NAME).docx

THEME = theme.yml
REFERENCE = custom-reference.docx
STYLE = tango

.PHONY: all
all: $(RESULT_PDF) $(RESULT_DOCX)

.PHONY: asciidoctor
asciidoctor: $(RESULT_PDF) $(RESULT_XML)

.PHONY: pandoc
pandoc: $(RESULT_DOCX)

.PHONY: clean
clean:
$(RM) $(RESULT_PDF) $(RESULT_XML) $(RESULT_DOCX)

$(RESULT_XML): $(ROOT_ASCIIDOC) $(CHAPTERS)
$(ASCIIDOCTOR) \
--backend docbook \
--out-file='$@' '$<'

$(RESULT_DOCX): $(RESULT_XML) $(REFERENCE)
$(PANDOC) \
--from docbook \
--reference-doc=$(REFERENCE) \
--highlight-style $(STYLE) \
--output '$@' '$<'
19 changes: 1 addition & 18 deletions LFD112x-RU/Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
ASCIIDOCTOR_PDF = asciidoctor-pdf

ROOT_ASCIIDOC_NAME = Course

CHAPTERS_DIR = Chapters
CHAPTERS = $(wildcard $(CHAPTERS_DIR)/*.adoc)

ROOT_ASCIIDOC = $(ROOT_ASCIIDOC_NAME).adoc
RESULT_PDF = $(ROOT_ASCIIDOC_NAME).pdf

THEME = theme.yml

.PHONY: all
all: $(RESULT_PDF)
include ../Common.mk

$(RESULT_PDF): $(ROOT_ASCIIDOC) $(CHAPTERS) $(THEME)
$(ASCIIDOCTOR_PDF) \
-r asciidoctor-mathematical \
-a mathematical-format=svg \
--theme $(THEME) \
--out-file='$@' '$<'

.PHONY: clean
clean:
$(RM) $(RESULT_PDF)
Binary file added LFD112x-RU/custom-reference.docx
Binary file not shown.
19 changes: 1 addition & 18 deletions LFD113x-RU/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
ASCIIDOCTOR_PDF = asciidoctor-pdf

ROOT_ASCIIDOC_NAME = Course

CHAPTERS_DIR = Chapters
CHAPTERS = $(wildcard $(CHAPTERS_DIR)/*.adoc)

ROOT_ASCIIDOC = $(ROOT_ASCIIDOC_NAME).adoc
RESULT_PDF = $(ROOT_ASCIIDOC_NAME).pdf

THEME = theme.yml

.PHONY: all
all: $(RESULT_PDF)
include ../Common.mk

$(RESULT_PDF): $(ROOT_ASCIIDOC) $(CHAPTERS) $(THEME)
$(ASCIIDOCTOR_PDF) \
--theme $(THEME) \
--out-file='$@' '$<'

.PHONY: clean
clean:
$(RM) $(RESULT_PDF)
Binary file added LFD113x-RU/custom-reference.docx
Binary file not shown.
5 changes: 3 additions & 2 deletions scripts/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Usage: $0 [OPTION]...
Build artifacts of the all courses
-h, --help print this help message and exit
-o, --out-dir DIRECTORY name of the DIRECTORY for all built artifacts
-s, --suffix SUFFIX SUFFIX for output pdf filename
-s, --suffix SUFFIX SUFFIX for output filename
Examples:
$0
Expand Down Expand Up @@ -79,7 +79,8 @@ fi
while IFS="" read -r line || [ -n "$line" ]
do
COURSE_NAME=$(get_info "$line" 1)
OUT_FILENAME="$(get_info "$line" 2)$SUFFIX.pdf"
OUT_FILENAME="$(get_info "$line" 2)$SUFFIX"

"$BASEDIR/build_course.sh" -o "$BUILDDIR/$OUT_FILENAME" "$COURSE_NAME"

done < "$COURSES"
13 changes: 10 additions & 3 deletions scripts/build_course.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ function usage() {
Usage: $0 [OPTION] COURSE_NAME
Build artifacts of the course with COURSE_NAME
-o, --out FILENAME output pdf FILENAME
-o, --out FILENAME output FILENAME without extension
-h, --help print this help message and exit
Examples:
$0 LFD113x-RU
$0 -o 'Инструментарий_и_компиляторные_оптимизации_для_RISC-V_(LFD113x)_RU.pdf' LFD113x-RU
$0 -o 'Инструментарий_и_компиляторные_оптимизации_для_RISC-V_(LFD113x)_RU' LFD113x-RU
tac
}


# Parse arguments
COURSEDIR=""
FILENAME=""
MAKEOPTS=()

while [ "$1" != "" ]; do
Expand All @@ -29,7 +30,7 @@ while [ "$1" != "" ]; do
exit 0
;;
-o|--out)
MAKEOPTS+=("RESULT_PDF=$2")
FILENAME=$2
shift 2
;;
-*)
Expand All @@ -56,5 +57,11 @@ if [ "$COURSEDIR" == "" ]; then
exit 1
fi

if [ "$FILENAME" != "" ]; then
MAKEOPTS+=("RESULT_DOCX=${FILENAME}.docx")
MAKEOPTS+=("RESULT_PDF=${FILENAME}.pdf")
MAKEOPTS+=("RESULT_XML=${FILENAME}.xml")
fi

# Build selected course
make -C "$COURSEDIR" "${MAKEOPTS[@]}"
5 changes: 3 additions & 2 deletions scripts/release_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ fi
# Release all files in build directory
while IFS="" read -r line || [ -n "$line" ]
do
OUT_FILENAME="$(get_info "$line" 2)$SUFFIX.pdf"
OUT_FILENAME="$(get_info "$line" 2)$SUFFIX"
LABEL=$(get_info "$line" 3)

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

0 comments on commit e69e607

Please sign in to comment.