Skip to content

Release

Release #22

Workflow file for this run

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/