-
Notifications
You must be signed in to change notification settings - Fork 2
143 lines (122 loc) · 4.89 KB
/
release.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Release
on:
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"
steps:
- name: Setup Git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update Ubuntu packages
run: sudo apt-get update
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: 'release'
- name: Setup pandoc
uses: r-lib/actions/setup-pandoc@v2
- name: Install rmarkdown
run: install.packages("rmarkdown")
shell: Rscript {0}
# Get previous version of user manual and create the next version
- name: Application Version
id: version
uses: paulhatch/semantic-version@v5.4.0
with:
tag_prefix: "v"
version_format: "v${major}.${minor}.${patch}"
bump_each_commit: false
# Create version.txt to use when changing the version in the tex file
- name: Create version.txt
run: |
echo ${{ steps.version.outputs.version }} > version.txt
# Update version and date in SS330_User_Manual.tex
- name: Update version and date in manual
run: |
version <- readLines("version.txt", encoding = "UTF-8")
version <- gsub("v", "", version)
manual_tex <- readLines("SS330_User_Manual.tex")
vers_vec <- paste0(c("[0-9].[0-9][0-9].[0-9][0-9]","[0-9].[0-9][0-9].[0-9][0-9].[0-9]"), collapse = "|")
manual_tex[grep("Version", manual_tex)] <- gsub(
pattern = vers_vec,
replacement = version,
x = manual_tex[grep(pattern = "Version", x = manual_tex)]
)
date_line <- grep(pattern = "date\\{", x = manual_tex)
todays_date <- format(x = Sys.Date(), "%B %d, %Y")
manual_tex[date_line] <- gsub(
pattern = "\\{[A-Za-z0-9, ]+",
replacement = paste0("{", todays_date),
x = manual_tex[date_line])
writeLines(text = manual_tex, con = "SS330_User_Manual.tex")
shell: Rscript {0}
- name: Remove version.txt before committing
run: rm version.txt
# Create HTML
- name: Convert tex to html
run: pandoc SS330_User_Manual.tex -s -o SS330_User_Manual.html --toc --embed-resources --standalone --mathjax --default-image-extension=png --number-sections --citeproc --variable linkcolor=#0033CC
- name: Run R script to create html
run: |
source(".github/r_code/edit_html_improve_formatting.R")
writeLines(html_txt, "docs/SS330_User_Manual_release.html")
file.remove("SS330_User_Manual.html")
shell: Rscript {0}
# Commit tex and html changes
- name: Commit changes of tex file version and html in docs folder to repo
uses: EndBug/add-and-commit@v9
with:
message: 'update tex file version and html in docs'
new_branch: update-tex-file-version
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.SS3-DOC-PAT }}
- name: Auto approve
if: steps.cpr.outputs.pull-request-operation == 'created'
run: gh pr review --approve "${{ steps.cpr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable Pull Request Automerge
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.SS3-DOC-PAT }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: squash
# Create PDF
- name: Compile LaTeX document
uses: xu-cheng/latex-action@v2
with:
root_file: SS330_User_Manual.tex
latexmk_use_lualatex: true
# Create Release
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ steps.version.outputs.version }}
release_name: ${{ steps.version.outputs.version }} Docs
draft: false
prerelease: false
body: SS3 User Manual for the ${{ steps.version.outputs.version }} Stock Synthesis release.
# Add PDF as artifact for release
- name: Upload release artifact - pdf manual
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./SS330_User_Manual.pdf
asset_name: SS330_User_Manual.pdf
asset_content_type: application/pdf
# Render user manuals to github pages
- name: Deploy to GitHub pages
uses: JamesIves/github-pages-deploy-action@4.1.4
with:
branch: gh-pages
folder: docs/