Skip to content

Commit

Permalink
Upgrade build process
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Sene <[email protected]>
  • Loading branch information
rpsene committed Jan 5, 2024
1 parent e38d8c1 commit 3efb5b5
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 14 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build Specification

on:
workflow_dispatch:
inputs:
version:
description: 'Release version, e.g. X.Y.Z:'
required: true
type: string
prerelease:
description: 'Tag as a pre-release?'
required: false
type: boolean
default: true
draft:
description: 'Create release as a draft?'
required: false
type: boolean
default: false
pull_request:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Build Docker Image
run: docker build -t latex-make-env .

- name: Run Container & Compile LaTeX
run: |
docker run --rm -v ${{ github.workspace }}:/data latex-make-env bash -c "\
git config --global --add safe.directory /data && \
make"
# Step 4: Upload the built PDF files as a single artifact
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: Specification Artifact
path: ${{ github.workspace }}/*.pdf
retention-days: 30

# Create Release
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/*.pdf
tag_name: v${{ github.event.inputs.version }}
name: Release ${{ github.event.inputs.version }}
draft: ${{ github.event.inputs.draft }}
prerelease: ${{ github.event.inputs.prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GHTOKEN }}
if: github.event_name == 'workflow_dispatch'
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use an official Ubuntu as a parent image
FROM ubuntu:latest

# Set noninteractive mode for apt-get
ARG DEBIAN_FRONTEND=noninteractive

# Update and install latex, git, make and other required tools
RUN apt-get update && \
apt-get install -y --no-install-recommends \
texlive-latex-base \
texlive-fonts-recommended \
texlive-fonts-extra \
texlive-latex-extra \
lmodern \
texlive-science \
make \
git && \
rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /data

# By default, run a shell
CMD ["/bin/bash"]
31 changes: 17 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
SPEC_TEX=riscv-trace-spec
SPEC=$(SPEC_TEX)
# Variables
SPEC_TEX := riscv-trace-spec
SPEC_PDF := $(SPEC_TEX).pdf
INCLUDES_TEX := introduction.tex branchTrace.tex exampleAlgorithm.tex filtering.tex timestamping.tex ingressPort.tex payload.tex dataTracePayload.tex control.tex preamble.tex riscv-trace-spec.tex decoder.tex discovery.tex exampleCodeSnippets.tex fragmentCodeAndTransport.tex future.tex

INCLUDES_TEX = introduction.tex branchTrace.tex exampleAlgorithm.tex filtering.tex timestamping.tex ingressPort.tex payload.tex dataTracePayload.tex control.tex preamble.tex riscv-trace-spec.tex decoder.tex discovery.tex exampleCodeSnippets.tex fragmentCodeAndTransport.tex future.tex
# Main Targets
all: $(SPEC_PDF)

all: $(SPEC).pdf
publish: $(SPEC_PDF)
cp $< $(SPEC_TEX)-`git rev-parse --abbrev-ref HEAD`.`git rev-parse --short HEAD`.pdf

$(SPEC).pdf: $(SPEC_TEX).tex $(INCLUDES_TEX) vc.tex
echo $(SPEC)
pdflatex -shell-escape $< && makeindex $(SPEC_TEX) && pdflatex -shell-escape $<
clean:
rm -f $(SPEC_PDF) *.aux *.toc *.log *.idx *.ilg *.ind *.lof *.lot *.out *.pdf

publish: $(SPEC).pdf
cp $< $(SPEC)-`git rev-parse --abbrev-ref HEAD`.`git rev-parse --short HEAD`.pdf
# Recipe for building the PDF
$(SPEC_PDF): $(SPEC_TEX).tex $(INCLUDES_TEX) vc.tex
echo $(SPEC_TEX)
pdflatex -shell-escape $< && makeindex $(SPEC_TEX) && pdflatex -shell-escape $<

# Recipe for generating vc.tex with Git version control information
vc.tex: .git/logs/HEAD
# https://thorehusfeldt.net/2011/05/13/including-git-revision-identifiers-in-latex/
echo "%%% This file is generated by Makefile." > vc.tex
echo "%%% Do not edit this file!\n%%%" >> vc.tex
git log -1 --format="format:\
Expand All @@ -22,11 +27,9 @@ vc.tex: .git/logs/HEAD
\\gdef\\GITAuthorDate{%ad}\
\\gdef\\GITAuthorName{%an}" >> vc.tex

# Recipe for generating changelog.tex from Git logs
changelog.tex: .git/logs/HEAD Makefile
echo "%%% This file is generated by Makefile." > changelog.tex
echo "%%% Do not edit this file!\n%%%" >> changelog.tex
git log --no-merges --date=short --pretty="format:vhEntry{%h}{%ad}{%an}{%s}" | \
sed -e "s,\\\\,{\\\\textbackslash},g" -e "s,[_#^],\\\\&,g" -e s/^/\\\\/ >> changelog.tex

clean:
rm -f $(SPEC).pdf *.aux $(SPEC).toc $(SPEC).log $(SPEC).aux $(SPEC).idx $(SPEC).ilg $(SPEC).ind $(SPEC).lof $(SPEC).log $(SPEC).lot $(SPEC).out $(SPEC).pdf $(SPEC).toc
sed -e "s,\\\\,{\\\\textbackslash},g" -e "s,[_#^],\\\\&,g" -e s/^/\\\\/ >> changelog.tex
Binary file removed riscv-trace-spec.pdf
Binary file not shown.

0 comments on commit 3efb5b5

Please sign in to comment.