-
-
Notifications
You must be signed in to change notification settings - Fork 90
122 lines (116 loc) · 4.11 KB
/
build.yml
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
name: Build document
on:
push:
tags: ["*"]
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Update Title
run: |
sudo apt install imagemagick fonts-freefont-ttf
export TEXT_FONT=FreeSans-Bold
export TEXT_SIZE=96
export TEXT_COLOR=LightGray
export TEXT="v $(git describe --tags)"
mogrify -stroke Black -fill Black -draw "rectangle 1090,2300 1390,2400" -stroke ${TEXT_COLOR} -fill ${TEXT_COLOR} -font ${TEXT_FONT} -pointsize ${TEXT_SIZE} -gravity Center -draw "text 0,600 '${TEXT}'" figures/MMM_cover.jpg
- name: LaTeX pass 1
uses: xu-cheng/latex-action@v2
with:
pre_compile: ./install_sagetex_sty.sh
compiler: pdflatex
args: --shell-escape
root_file: main-moonmath.tex
- name: LaTeX pass 2
uses: xu-cheng/latex-action@v2
with:
compiler: pdflatex
args: --shell-escape
root_file: main-moonmath.tex
- name: SageMath pass
uses: wuan/sagemath-action@v1
with:
source_file: main-moonmath.sagetex.sage
- name: LaTeX final iterations
id: latex-final
uses: xu-cheng/latex-action@v2
with:
root_file: main-moonmath.tex
- name: Collect Warnings
id: warnings
run: |
echo "WARNINGS<<EOF" >> $GITHUB_ENV
grep "^LaTeX Warning" main-moonmath.log | cut -d" " -f3- | tee -a $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
continue-on-error: true
- name: Upload PDF
uses: actions/upload-artifact@v3
with:
name: MoonMath Manual PDF
path: main-moonmath.pdf
- name: Upload generated files
uses: actions/upload-artifact@v3
with:
name: MoonMath Manual generated files
path: |
tmp/*
sage-plots-for-main-moonmath.tex/*
- name: Update PR with warnings found
uses: actions/github-script@v6
continue-on-error: true
if: github.event_name == 'pull_request'
env:
WARNINGS: "${{ env.WARNINGS }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// 1. Retrieve existing bot comments for the PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
const botComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes('Moonmath Manual build')
})
// 2. Prepare format of the comment
const output = `#### Moonmath Manual build
<details><summary>WARNINGS</summary>\n\n
\`\`\`
${process.env.WARNINGS}
\`\`\`
</details>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Workflow: \`${{ github.workflow }}\`*`;
// 3. If we have a comment, update it, otherwise create a new one
const comment_data = {
owner: context.repo.owner,
repo: context.repo.repo,
body: output
}
if (botComment) {
comment_data.comment_id = botComment.id
github.rest.issues.updateComment(comment_data)
} else {
comment_data.issue_number = context.issue.number
github.rest.issues.createComment(comment_data)
}
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: Release ${{ github.ref_name }}
artifacts: main-moonmath.pdf
artifactContentType: application/pdf